WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Double Meta Tags in Category Pages

[Resolved] Double Meta Tags in Category Pages

  • Yet Another WP User

    @yet-another-wp-user

    Hello everyone

    I am running a wordpress blog. I have manually added a noindex tag using following code in header.php file:

    <?php if ( is_paged() || is_search() ) { ?>
    <meta name=”robots” content=”noindex,follow” />

    I am also using AIO SEO plugin and I have set it to noindex category, archive and tags pages.

    Now the problem is the paged pages of categories such as “category/windows/page/2/” is showing duplicate meta tag:

    <meta name=”robots” content=”noindex,follow” />

    One is getting added by header.php file and the other by the plugin.

    I want to know is it ok to have it twice or can I add some code in header.php file to have it only once?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Yet Another WP User

    @yet-another-wp-user

    Just to add more details! I added the code manually in header.php file to set noindex for index paged pages such as homepage.com/page/2, etc. Now its also applying to category paged pages.

    So basically I want to set the noindex only for Index paged pages and not for category paged pages.

    Yet Another WP User

    @yet-another-wp-user

    Ok. I found the solution myself. Using following now:

    <?php if ( is_paged() && is_front_page() ) { ?>
    <meta name="robots" content="noindex,follow" />
    <?php } ?>
    <?php if ( is_search() ) { ?>
    <meta name="robots" content="noindex,follow" />
    <?php } ?>

    So now noindex is set to only those paged pages which are part of homepage. So its not applying to category paged pages and no more duplicate noindex meta tag. 🙂

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Double Meta Tags in Category Pages’ is closed to new replies.