WordPress.org

Ready to get started?Download WordPress

Forums

How to make search engines index posts instead of categories? (5 posts)

  1. zimzam
    Member
    Posted 9 years ago #

    Hi,

    I was wondering if it were possible to force search engines to only index individual post pages instead of category pages. The problem is that when keywords are searched for and a category link of the form http://www.site.com/index.php?cat=1 is returned, the post that the search returned is unlikely to be there (more likely it was a older post in the same category and is no longer one of the first few shown).

    The user would then have no choice but to use the built in search tool on the WP blog, but that's annoying.

    I've read about robots.txt but I don't know how I could apply it to the dynamic pages generated by WP. Anyone know how to stop category/monthly/yearly pages from being indexed and only the post pages?

  2. Kafkaesqui

    Posted 9 years ago #

    You could add this to the <head> section of your template:

    1.5:
    <?php if((!is_home()) && (!is_single())) : ?>
    <meta name="robots" content="noindex,follow">
    <?php endif; ?>

    1.2:
    <?php if((!empty($_SERVER['QUERY_STRING'])) && (!$single)) : ?>
    <meta name="robots" content="noindex,follow">
    <?php endif; ?>

    It won't take care of all search engines, but the big ones tend to abide by it.

  3. zimzam
    Member
    Posted 9 years ago #

    Thanks so much! I'll give it a try!

  4. walternet
    Member
    Posted 8 years ago #

    The following code works perfectly with 2.0...

    <?php if((!is_home()) && (!is_single())) : ?>
    <meta name="robots" content="noindex,follow">
    <?php endif; ?>

    ... but I'd like to add the single pages (info, etc...) to the indexed pages too.

    Could someone help me? :-)

  5. joshuamcgee
    Member
    Posted 8 years ago #

    walternet,

    2.0:
    <?php if((!is_home()) && (!is_page()) && (!is_single())) : ?>
    <meta name="robots" content="noindex,follow">
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.