All in One SEO (Pro)
If you are using All in One SEO or All in One SEO Pro together with FacetWP, be aware of the following two incompatibilities:
Fix no results after filtering
In specific situations, AIOSEO (Pro) will cause a JSON error in the AJAX refresh data that is returned to FacetWP after filtering. This will cause FacetWP to be unable to process the response, resulting in a “no results” message, or simply no posts showing up.
Fortunately there is an easy fix.
Triggers
The following factors all need to be present to trigger this error:
- All in One SEO (Pro) is installed.
- As listing template you are using a WP archive page, a custom WP_Query, or a page builder query. The issue does not happen when you are using a Listing Builder listing template.
- Your active theme does not have support for the ‘title-tag’ feature. This causes AIOSEO to use PHP output buffering to customize the theme’s
<title>
tag, which in turn is the cause of these issues.
How to test for ‘title-tag’ theme support
To quickly test if your theme has support for the title-tag
feature, you can temporarily add the following to your theme’s functions.php:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
// Remove after testing add_action( 'after_setup_theme', function() { var_dump( current_theme_supports( 'title-tag' ) ); // outputs bool(false) if 'title-tag' is not supported, or bool(true) if 'title-tag' is supported } );
If you see the output bool(false)
, your theme does not have this feature, and you can apply the fix below to add support for it.
If it outputs bool(true)
, your theme does already support this feature, which means that the “no results” issue is not caused by the AIOSEO plugin.
What is the ‘title-tag’ feature?
Before WordPress version 4.1, the only way to dynamically generate <title>
tags based on the page/post title was by using the wp_title() function in the <head>
section of the theme. To customize its output, theme authors could use the wp_title hook.
In version 4.1, WordPress introduced a new way of generating title tags, by letting WP Core handle their generation and output. Since then, the <title>
tag can be customized with a range of new filters, like the document_title_parts hook. The wp_title()
function was deprecated (but later reinstated again). The use of wp_title()
is now discouraged.
By declaring 'title-tag'
support, themes acknowledge that they are not defining titles on their own and WordPress can safely add them without duplication.
The fix: add ‘title-tag’ support
Most modern themes have 'title-tag'
support. If your theme does not have it, you can enable it by adding the following code to your theme’s functions.php:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
add_action( 'after_setup_theme', function() { add_theme_support( 'title-tag' ); } );
If you do this, you have to remove any uses of wp_title()
in the <head>
section (generally in your theme’s header.php file), to prevent duplicate title tags.
Alternative fix: disable title rewrites by All in One SEO
If you don’t want to add ‘title-tag’ support to your theme, an alternative fix is to disable <title>
rewrites by AIOSEO. You can limit this to your facet page like this:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
add_filter( 'aioseo_disable_title_rewrites', function( $disabled ) { if ( is_page('my-facet-page') ) { return true; // disable AOISEO title rewrites } return false; } );
Or you can apply it site-wide:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
add_filter( 'aioseo_disable_title_rewrites', function( $disabled ) { return true; // disable AOISEO title rewrites } );
Be careful with this, as it could potentially hurt your SEO.
Fix AIOSEO URL redirects
Since version 4.2.1, AIOSEO has a setting called Crawl Cleanup, found in the section: Search Appearance > Advanced > Crawl Cleanup.
If you have enabled Crawl Cleanup, make sure to disable the “Remove Query Args” setting:
If this setting is enabled, query arguments will be automatically removed from the URL, and the page will get a 301
redirect to the URL without any facet selections. This breaks facet filtering.
Note that query arguments are only removed by this setting when you are not logged in.