1

I would like to write some code that remove from google the tag pages which contains only a few posts.

I can do it by modifying the meta tag and the HTTP response header to 410. But how can I implement that in Wordpress?

1 Answer 1

2

You can use http://php.net/manual/en/function.http-response-code.php to set the response header, and you just need to find the lines in the theme's header.php. Unfortunately, these items are set by header.php so you will have to run the code on all pages of a traditional theme, but I would do something in the header.php near where the meta is currently being set like

if ( is_tag() ){
// check for how many posts are in the loop here and save as number
}
if (is_tag() && $number < 3){
//change meta here, change http response code here
}
else{
// normal meta here, normal response code here
}
1
  • But how do I check how many posts are in that tag?
    – Revious
    May 21, 2015 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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