0

My site is auto importing feed of other website. Obviously it's copied content for google. So i want to noindex all posts comes from that feed. Thanks

1

Being excluded-cat and excluded-cat-1 the categories you want to exclude from indexing:

add_action('wp_head','AS_exclude_category_from_indexing');

function AS_exclude_category_from_indexing(){
  $html="";
  if(has_category('excluded-cat') || has_category('excluded-cat-1')){
    $html= "<meta name=\"robots\" content=\"noindex,follow\">".PHP_EOL;
  } 
  echo $html;
}
3
  • thank you for you reply i found this code and worked - /* Noindex all posts in a category */ add_filter("wpseo_robots", function($robots) { if (is_single() && in_category(array(10588, 13416))) { return "noindex,follow"; } return $robots; });
    – mukesh
    Feb 5 '20 at 11:14
  • wpseo_robots is not a native WP filter, I guess is Wp Yoast, in case you do't use that plugin this filter won't work Feb 5 '20 at 11:43
  • yes i'm using yoast plugin.
    – mukesh
    Feb 6 '20 at 3:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.