Why do I see no results after using facets?
When there are no results in the listing (actually nothing, or a “no results” message) after using facets, but results do appear after a hard page reload, more often than not the issue is a malformed HTML structure of the page. This happens quite often, for example by accidentally copy-pasting a piece of code in the wrong spot.
On AJAX refresh, when using facets, FacetWP processes the HTML between the first opening <body>
tag and the first closing </body>
tag. When there are multiple opening or closing <body>
tags on the page, or if they are missing, or in the wrong place, the processed content/template will not include the listing/results, causing the “no results” issue to happen.
So, if you see this issue, open the page source in your browser, copy the whole HTML into an editor, and check if your HTML structure is sound. Make sure all opening and closing <html>
</html>
, <head>
</head>
and <body>
</body>
tags are present, in the right place, and appearing only once. Pay special attention to the opening <body>
and closing </body>
tags.
Diagnosing issues with the Console Network XHR Response tab
Another way to diagnose the “no results” issue (and other refresh issues) is to use the browser Console.
Open the Console, then click the “Network” tab. Reload the page, then select the “XHR” tab, and use a facet. You’ll see an item appear that represents the AJAX refresh. Click on the item so the info about it appears. In the “Response” tab of this info will be the JSON that represents the refreshed content:
If you copy the HTML of the “template” part of the JSON response to an editor, you can check whether that HTML is structured right and if it includes the results. If it does not, check your template file and/or its includes (like the header.php and footer.php files) for stray, duplicate, missing, or unclosed <html>
, <head>
and <body>
tags.
Note that this issue will never happen when using a Listing Builder listing template, because this type of template is processed differently. It can happen on all other supported listing templates though.
Other possible causes for no results
A few other possible causes for seeing “no results” (with or without using facets):
- When using All in One SEO (Pro) in combination with a theme that does not support the “title-tag” feature.
- When using SearchWP on the default search result page (without facets on the page).
- When using Relevanssi and the Relevanssi add-on on the default search result page (without facets on the page).
- When using WPML or Polylang together with the Multilingual add-on, without having everything set up correctly. Basically, all posts need to have an explicit language set and must have a translation. And if you are using facets on a listing that has only posts without a language set, you need to tell FacetWP to ignore its language parameter.
- A JSON parse error, which is visible as an error in the XHR Response tab (as explained above). This is usually caused by a plugin or the theme incorrectly appending part of the page HTML to the JSON response, often caused by improperly opened or closed
ob_*()
(output buffering) functions. The source of this can sometimes be hard to find. You can disable all but necessary plugins to find the culprit (for example with the Health Check & Troubleshooting plugin), or search your plugins and theme forob_
strings with your editor or the String Locator plugin. Another possible cause of JSON errors is a plugin or even the server incorrectly filtering the return data as if it’s HTML, even though it is not. That is an even more difficult issue to diagnose. Contact support if you need help with this.
When you see “FacetWP was unable to auto-detect the post listing” instead of no results, this FAQ answer lists a few possible causes.