jenny-r
2/20/2018 - 10:01 PM

facetwp check category listing query for listify

facetwp check category listing query for listify

<?php
// check for job_listings archive and don't use the query unless it is using menu_order
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
	if ( isset( $query->query_vars['post_type'] ) && 'job_listing' == $query->query_vars['post_type']
	     && ( ! isset( $query->query_vars['taxonomy'] ) || '' == $query->query_vars['taxonomy'] ) ) {
		if (  isset( $query->query_vars['order_by']['menu_order'] ) ) {
			return true;
		} else {
			return false;
		}
	}
	if ( is_tax('job_listing_category' ) && 'job_listing' != $query->get('post_type') ) {
		return false;
	}  
	return $is_main_query;
}, 10, 2 );