Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a wordpress blog set up on my site, example "blog.domain1.com". I have several categories and write posts under each category. I have one specific category that I don't want google search to show on the results page and also the articles written under this category. I used robots.txt and added this Disallow: /category/profiles Disallow: /category/profiles/feed

But when I search the content of the posts by doing site search, it appears in google results. How do I hide these posts from google? I used a plug in to hide these posts on blog.domain1.com home page, search page.

Why I am doing this - I have another domain example "domain2.com" where I cannot install wordpress so I decided to use a parsing script that will fetch content from my other domain for the posts written under that one specific category "profiles".

How I am doing this -

I created a custom feed script that will have posts only from specific category "profiles". the url will be like this blog.domain1.com/custom-feed. I use this url on my domain2.com script to show the articles.

Can you please help me to take of hiding these specific posts from google search results so that google doesn't think I have duplicate content. I had to do this way because of restrictions that I cannot install wordpress there. Also, no resource for me to do manual work by just creating a static page with content on my domain2.com. To automate it, I used a parser script and then whenever an article is written on blog.domain1.com, it will appear on this domain2.com.

Please clarify.

regards

share|improve this question
    
I'm pretty sure (and hopefully someone will correct me) that robots.txt is just a "suggestion" and not a fool-proof way to keep the googlebot out. It is up to the bot to respect your settings, which is probably not guaranteed. –  helgatheviking Mar 15 '13 at 18:40

1 Answer 1

up vote 1 down vote accepted

Hook into the action wp_head, test if you are on the category archive or a single post with that category, and print the proper meta element:

add_action( 'wp_head', 'wpse_91073_noindex' );

function wpse_91073_noindex()
{
    if ( ( is_singular() && in_category( 'CATEGORY_SLUG' ) ) 
        or is_category( 'CATEGORY_SLUG' )
    )
    {
        print '<meta name="robots" content="noindex">';
    }
}

Replace CATEGORY_SLUG with the real slug of the category (you can find that in wp-admin/edit-tags.php?taxonomy=category).

share|improve this answer
    
Thanks will do this but how this will take care of the Post page doesn't have the category in the url. Sorry, if I am asking something that this function will take care of. –  Jay Mar 15 '13 at 20:25
    
The URL is not needed for this solution. WordPress will look at the post object(s), not at the URL. –  toscho Mar 15 '13 at 20:26
    
thanks..i thought google index the site and show it on search results so in that case when google index the site it will automatically catch this post/article right? –  Jay Mar 15 '13 at 20:28
    
Yes, it will read the meta element during the next crawl and probably respect it. –  toscho Mar 15 '13 at 20:30
    
ok cool, thanks. what is wpse_91073_noindex in the function? –  Jay Mar 15 '13 at 20:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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