SHOW:
|
|
- or go back to the newest paste.
| 1 | - | function ac_search_mod($query) {
|
| 1 | + | <?php |
| 2 | - | if(is_search()) {
|
| 2 | + | |
| 3 | - | $ac_tax_query = array( |
| 3 | + | add_action( 'pre_get_posts', 'ac_show_search_results' ); |
| 4 | - | array( |
| 4 | + | |
| 5 | - | 'taxonomy' => 'ac_state', |
| 5 | + | function ac_show_search_results( $query ) {
|
| 6 | - | 'terms' => $_GET['funeral-state'] |
| 6 | + | |
| 7 | - | 'field' => 'name', |
| 7 | + | if ( ! $query->is_page( 'some-page-slug' ) ) |
| 8 | - | ), |
| 8 | + | return; |
| 9 | - | array( |
| 9 | + | |
| 10 | - | 'taxonomy' => 'ac_city', |
| 10 | + | $tax_query = array(); |
| 11 | - | 'terms' => $_GET['funeral-city'], |
| 11 | + | |
| 12 | - | 'field' => 'name', |
| 12 | + | if ( ! empty( $_GET['funeral-state'] ) ) {
|
| 13 | - | ) |
| 13 | + | $tax_query[] = array( |
| 14 | 'taxonomy' => 'ac_state', | |
| 15 | 'terms' => $_GET['funeral-state'], | |
| 16 | - | $query->set('tax_query', $ac_tax_query);
|
| 16 | + | 'field' => 'name', |
| 17 | ); | |
| 18 | - | } |
| 18 | + | |
| 19 | - | add_action('pre_get_posts', 'ac_search_mod'); |
| 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 | } |