Advertisement
mbis

No-index faceted links

Jun 11th, 2019
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. function pm_noindex_faceted_links() {
  2.     // Get all query parameters and check if any facet parameter is set
  3.     if(!empty($_GET)) {
  4.         $get_parameters = $_GET;
  5.  
  6.         foreach($get_parameters as $parameter => $value) {
  7.             if(strpos($parameter, 'fwp_') !== false) {
  8.                 // Yoast SEO support
  9.                 add_filter('wpseo_robots', '__return_false');
  10.  
  11.                 wp_no_robots();
  12.                 break;
  13.             }
  14.         }
  15.     }
  16. }
  17. add_action('wp_head', 'pm_noindex_faceted_links');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement