// FacetWP Debugging

Use the following steps to help diagnose and fix FacetWP issues.

First steps

Here’s some scenarios for when facets wouldn’t appear:

  • Does a template exist on the page?
  • Do some facets exist on the page (either shortcodes or PHP)?
  • Your post type needs exclude_from_search = FALSE (re-index afterwards)

Other scenarios may include:

Turn on Debug Mode

Within Settings > FacetWP > Settings, turn Debug Mode on.

debug mode

Using the browser console

When Debug Mode is enabled, FacetWP adds extra data into each AJAX response. To access it, open your browser console and type FWP.settings.debug:

open browser console

Check for javascript errors

When you first open the browser console, you may see some errors. Look closely at these errors because they sometimes pinpoint the issue.

For example, if a Proximity facet or map doesn’t work and you see an error like below, you likely just need to enter an API key 🙂

console warning

Looking at the query

You can view the query arguments, SQL, and pager data by typing the following into the console:

FWP.settings.pager;
FWP.settings.debug.query_args;
FWP.settings.debug.sql;

First, look at the pager. If the counts look wildly off, then FacetWP is using the wrong query:

pager data

Next, look at the query_args. Does the post_type property match what you’re expecting?

query arguments

The SQL is harder to explain, but look through it and see if you can spot any abnormalities. Perhaps the WHERE clause is adding extra stuff (added by another plugin) that you weren’t expecting.

FacetWP is using the wrong query

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 );

Further steps

If you still need help, feel free to contact support (and leave Debug Mode on).