Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

How to add meta tag to specific category posts?

         

jambam

10:42 am on Apr 9, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi my site is in google news however I want to make sure I stay there and so i want to exclude certain posts in certain categories from appearing in google news by using the meta tags
<meta name="Googlebot-News" content="noindex, nofollow">
How can I add this code to certain posts in specific categorys suh as "how to" and "rants" which arent news.

oddly there is not much info on this on the internet.

Would be helpful if someone could help me out. Thank you!

not2easy

3:36 pm on Apr 9, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



The simplest way would be to use robots.txt, but because it is WordPress there is more than one way to find the content.
This is not a paste-in cure because I am not familiar with the specific Googlebot-News UA - you should edit this to fit your needs:
User-agent: Googlebot-News
Disallow: /*rants
Disallow: /*how to

That conveys that any content with /rants/ or /how to/ in the URL is off limits for that bot whether it is /archives/rants/ or /category/rants/

The Yoast SEO plugin lets you add custom metatags on a per post basis. (that part is still free)

Januar

6:06 pm on Jun 27, 2017 (gmt 0)

5+ Year Member



You can use Yoast SEO plugin. I think it's a good plugin for adding meta tag for all o your blog's pages.

londrum

6:21 pm on Jun 27, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



if you don't mind fiddling with your template files then you can check which category the post is in, and then add the meta tag with something like this:
if(in_category(array('blah1','blah2'))) {
echo'<meta name="Googlebot-News" content="noindex, nofollow">';
}


blah1 and blah2 are the slug names of your categories