→ Debugging CSS-based templates

For CSS-based templates, FacetWP will automatically try to find the right query.

$is_main_query = ( $query->is_archive || $query->is_search || ( $query->is_main_query() && ! $query->is_singular ) );

FacetWP uses the first query that matches the above criteria. This usually works great, but sometimes it’s necessary to give FacetWP some guidance on which query to use.

No results

FacetWP was unable to auto-detect the post listing

If you’re seeing this error, it’s because FacetWP can’t find a suitable query. This usually happens when there’s a custom WP_Query on a standard WordPress page. See the Usage section on the facetwp_is_main_query page for the solution.

Turn on debug mode

If FacetWP isn’t filtering correctly, it’s because FacetWP is using the wrong query. For example, if you have a custom WP_Query or query_posts() on the default search page, FacetWP may be using the default query instead of your new one.

To find which query FacetWP is using, start by adding this line to wp-config.php:

define( 'FACETWP_DEBUG', true );

Finding the query

Browse to your facet listing, open the browser console, and type in:


This will return the selected query’s arguments (as a javascript object), as well as the SQL.


Here’s an example of the query_args object (containing WP_Query arguments):


Ignore irrelevent queries

Let’s say you’ve determine that FacetWP is incorrectly using a query with 'post_type' => 'edd_wish_list'. We’ll just need to tell FacetWP to ignore the query, using the facetwp_is_main_query filter.

function fwp_ignore_query( $is_main_query, $query ) {
    if ( 'edd_wish_list' == $query->query_vars['post_type'] ) {
        $is_main_query = false;
    return $is_main_query;
add_filter( 'facetwp_is_main_query', 'fwp_ignore_query', 10, 2 );