Advertisement
Viper007Bond

Untitled

Jun 28th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. add_action( 'pre_get_posts', 'ac_show_search_results' );
  4.  
  5. function ac_show_search_results( $query ) {
  6.  
  7.     if ( ! $query->is_page( 'some-page-slug' ) )
  8.         return;
  9.  
  10.     $tax_query = array();
  11.  
  12.     if ( ! empty( $_GET['funeral-state'] ) ) {
  13.         $tax_query[] = array(
  14.             'taxonomy' => 'ac_state',
  15.             'terms'    => $_GET['funeral-state'],
  16.             'field'    => 'name',
  17.         );
  18.     }
  19.  
  20.     if ( ! empty( $_GET['funeral-city'] ) ) {
  21.         $tax_query[] = array(
  22.             'taxonomy' => 'ac_city',
  23.             'terms'    => $_GET['funeral-city'],
  24.             'field'    => 'name',
  25.         );
  26.     }
  27.  
  28.     if ( ! empty( $tax_query ) )
  29.         $query->set( 'tax_query', $tax_query );
  30.  
  31.     if ( ! empty( $_GET['ac-search'] ) )
  32.         $query->set( 's', $_GET['ac-search'] );
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement