Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'pre_get_posts', 'ac_show_search_results' );
- function ac_show_search_results( $query ) {
- if ( ! $query->is_page( 'some-page-slug' ) )
- return;
- $tax_query = array();
- if ( ! empty( $_GET['funeral-state'] ) ) {
- $tax_query[] = array(
- 'taxonomy' => 'ac_state',
- 'terms' => $_GET['funeral-state'],
- 'field' => 'name',
- );
- }
- if ( ! empty( $_GET['funeral-city'] ) ) {
- $tax_query[] = array(
- 'taxonomy' => 'ac_city',
- 'terms' => $_GET['funeral-city'],
- 'field' => 'name',
- );
- }
- if ( ! empty( $tax_query ) )
- $query->set( 'tax_query', $tax_query );
- if ( ! empty( $_GET['ac-search'] ) )
- $query->set( 's', $_GET['ac-search'] );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement