For all types listing templates, FacetWP will automatically try to find the right query. This usually works great, but sometimes FacetWP needs some extra guidance on which query to use.

The WordPress loop

FacetWP tries to automatically add a facetwp-template CSS class to an element surrounding the Loop. But due to a myriad of circumstances, sometimes it needs to be done manually.

If so, wrap the CSS class around both the if ( have_posts() ) and else statements, as shown below).

<div class="facetwp-template">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <?php get_template_part( 'content', 'post' ); ?>
    <?php endwhile; else : ?>
        <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>

The file to edit depends on several factors. As a general rule:

Search page: search.php
Main archive: archive.php
Category archive: category.php
Blog home: home.php
WooCommerce shop: archive-product.php

See WordPress’ built-in Template Hierarchy.

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.

To find which query FacetWP is using, go to Settings > FacetWP > Settings, and turn on Debug Mode.

Finding the query

To find the query FacetWP is using, browse to your facet listing, open your browser’s code inspector, go to the Console tab, and type in:


This will return lots of debugging data, including the query arguments and SQL.


Ignore irrelevant queries

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

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( 'edd_wish_list' == $query->get( 'post_type' ) ) {
        $is_main_query = false;
    return $is_main_query;
}, 10, 2 );

See also