Viper007Bond

Untitled

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