FacetWP Listing Template Issue
January 31, 2025 · AI Conversations
### 1. **Ensure FacetWP is Installed and Activated**
– Go to **Plugins > Installed Plugins** and check that FacetWP is active.
### 2. **Check the Listing Query**
– FacetWP needs to detect a **WP_Query**, **a loop**, or a supported listing system.
– If you're using a custom query, wrap it in `facetwp_is_main_query()`.
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
);
if ( function_exists( 'facetwp_is_main_query' ) && facetwp_is_main_query() ) {
$query = new WP_Query( $args );
} else {
$query = new WP_Query( $args );
}
### 3. **Ensure FacetWP Integration is Added to the Loop**
– Wrap your loop with the `facetwp-template` class:
<div class="facetwp-template">
<?php if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php endwhile; ?>
<?php else : ?>
<p>No results found.</p>
<?php endif; ?>
</div>
### 4. **Check for AJAX Compatibility**
– Ensure that the listing is inside a container with the class `facetwp-template`, so FacetWP knows where to apply filtering.
### 5. **Use a Compatible Listing Plugin**
– If you're using a page builder (like Elementor, Divi, or Avada), make sure your listing is compatible with FacetWP.
– If using **Elementor**, check if the listing is inside a FacetWP-supported widget or switch to a theme template.
### 6. **Re-index FacetWP**
– Go to **Settings > FacetWP** and click **Re-index**.
– Then, clear the cache.
### 7. **Test with a Default Theme**
– Temporarily switch to a default theme like **Twenty Twenty-Four** and see if FacetWP detects the listing.
### 8. **Check for JavaScript Errors**
– Open your browser’s **Developer Console** (`F12` in Chrome/Firefox).
– Check for errors that might be preventing FacetWP from functioning.
### 9. **Manually Trigger FacetWP**
– If FacetWP still doesn't detect your listing, try forcing detection:
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
if ( isset( $query->query_vars['post_type'] ) && 'your_post_type' === $query->query_vars['post_type'] ) {
return true;
}
return $is_main_query;
}, 10, 2 );
If none of these steps work, let me know your specific setup (theme, listing method, and any custom queries used), and I can provide a tailored fix!