If you want to make absolutely sure that URLs with FacetWP query variables are not indexed, and you are using the SEOPress, you can use the filter meta robots noindex to change the robots meta tag from index
to noindex
for pages with facet choices in the URL.
Add the following code to your (child) theme’s functions.php:
add_filter('seopress_titles_robots_attrs', 'sp_titles_robots_attrs');
function sp_titles_robots_attrs($attrs) {
if ( function_exists( 'FWP' ) && ! FWP()->request->is_refresh && ! empty(
FWP()->request->url_vars ) ) {
unset($attrs);
$attrs = ['noindex,follow'];
}
return $attrs;
}
WARNING: Use this at your own risk, test it thoroughly to not mess up your SEO.
The above code changes the robots meta tag only for directly loaded URLs with a FacetWP query string containing facet choices, including FacetWP pagination and sorting.
Last modified: November 6, 2023