wpf_should_filter_query

#Overview

WP Fusion’s Filter Queries option allows you to modify the results of database queries to exclude content that a user can’t access (based on WP Fusion’s access rules).

There are some situations where you may need to bypass query filtering on a specific post type or in a certain context, in that case you can use the wpf_should_filter_query filter.

#Parameters

  • $should_filter (bool): Whether or not to apply query filtering to the query
  • $query (WP_Query): The query

#Examples

#Bypass query filtering on the home page if the post type is an event

This example bypasses query filtering on the The Events Calendar events list if the current page is the home page.

function bypass_filter_queries_for_events( $should_filter, $query ) {

	if ( is_front_page() && 'tribe_events' == $query->get( 'post_type' ) ) {
		return false;
	}

	return $should_filter;

}

add_filter( 'wpf_should_filter_query', 'bypass_filter_queries_for_events', 10, 2 );

Was this helpful?