WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Double Meta Tags in Category Pages (3 posts)

  1. Yet Another WP User
    Member
    Posted 1 year ago #

    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.

  2. Yet Another WP User
    Member
    Posted 1 year ago #

    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.

  3. Yet Another WP User
    Member
    Posted 1 year ago #

    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.]

Topic Closed

This topic has been closed to new replies.

About this Topic