If you want to make absolutely sure that URLs with FacetWP query variables are not indexed, and you are using the Yoast SEO plugin, you can use the wpseo_robots filter 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( 'wpseo_robots', function( $robots ) {
if ( function_exists( 'FWP' ) && ! FWP()->request->is_refresh && ! empty( FWP()->request->url_vars ) ) {
returnstr_replace( 'index', 'noindex', $robots );
  }
return$robots;
} );

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.

Worth mentioning is that Yoast SEO automatically removes the canonical link tag when the robots meta tag is set to “noindex”, because it is not necessary for that situation.

Was this article helpful?
YesNo

Leave a Reply

Your email address will not be published. Required fields are marked *

Close Search Window