Created
December 30, 2015 16:36
-
-
Save Kenshino/617e945052bb7b79f2cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wingz_exhibitor_filter(){ | |
global $wp_query; | |
$tax_query = array( 'relation' => 'AND' ); | |
if ( isset( $_GET['s'] ) ): | |
$search = sanitize_text_field( $_GET['s'] ); | |
else: | |
$search = ''; | |
endif; | |
if ( isset( $_GET['exhibitor_type'] ) && $_GET['exhibitor_type'] != '' ): | |
$exhibitor_type = sanitize_text_field( $_GET['exhibitor_type'] ); | |
$tax_query[] = array( | |
'taxonomy' => 'exhibitor_type', | |
'field' => 'term_id', | |
'terms' => $exhibitor_type, | |
); | |
endif; | |
if ( isset( $_GET['exhibitor_category'] ) && $_GET['exhibitor_category'] != '' ): | |
$exhibitor_category = sanitize_text_field( $_GET['exhibitor_category'] ); | |
$tax_query[] = array( | |
'taxonomy' => 'exhibitor_category', | |
'field' => 'term_id', | |
'terms' => $exhibitor_category, | |
); | |
endif; | |
if ( isset( $_GET['exhibitor_country'] ) && $_GET['exhibitor_country'] != '' ): | |
$exhibitor_country = sanitize_text_field( $_GET['exhibitor_country'] ); | |
$tax_query[] = array( | |
'taxonomy' => 'exhibitor_country', | |
'field' => 'term_id', | |
'terms' => $exhibitor_country, | |
); | |
endif; | |
if ( isset( $_GET['exhibitor_designstyle'] ) && $_GET['exhibitor_designstyle'] != '' ): | |
$exhibitor_designstyle = sanitize_text_field( $_GET['exhibitor_designstyle'] ); | |
$tax_query[] = array( | |
'taxonomy' => 'exhibitor_designstyle', | |
'field' => 'term_id', | |
'terms' => $exhibitor_designstyle, | |
); | |
endif; | |
$args = array( | |
's' => $search, | |
'posts_per_page' => -1, | |
'post_type' => 'exhibitor', | |
'tax_query' => $tax_query, | |
'meta_key' => '_wingz-ad-priority', | |
'orderby' => array( 'meta_value_num' => 'DESC', 'title' => 'ASC' ), | |
); | |
$wp_query = new WP_Query( $args ); | |
get_template_part( 'loop', 'exhibitor' ); | |
wp_reset_postdata(); | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment