• zimzam

    (@zimzam)


    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 https://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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Kafkaesqui

    (@kafkaesqui)

    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.

    Thread Starter zimzam

    (@zimzam)

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

    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? ??

    walternet,

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to make search engines index posts instead of categories?’ is closed to new replies.