[Support request] Archive and thin content entries – how to stop

Home Forums Support [Support request] Archive and thin content entries – how to stop

Home Forums Support Archive and thin content entries – how to stop

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2174360
    steven

    Hi,

    I hope you can help. Is it possible to stop archive posts/pages from being generated by the theme. The issue is these are being indexed by Google (which I don’t want), and I’d rather stop having to take action.

    Action I have taken: I have added the following code to header.php in the theme:

    <?php
    // Noindex duplicates – author, date archive, pagination, tags, 404, search
    if( is_author() | is_date() | is_paged() | is_tag() | is_404() | is_search()) {
    _e(‘<meta name=”robots” content=”noindex, follow” />’);
    } ?>

    In addition:

    Author archives: I went through last 3 months of data in Google Search console and redirected ALL indexed author archives to my homepage.

    I then manually requested to remove all of those author archives from the index.

    Is there any way of stopping these posts/pages being generated in future? It’s a pain having to clean this up and I don’t want unforeseen effects, like eno indexing posts that I DO want (I am not a coder, but I can sort of understand the code).

    But the code is a workaround. I’d rather address the root cause if possible.

    Thanks so much for your time!

    Steve

    #2174507
    Longinos

    Hi
    Most of those things are how wordpress work.
    You need code (or a plugin) to make these pages noindex, redirect or even do no produce it.
    Whit Yoast SEO plugin you can choose noindex for categories and tag pages, don´t have archives by date or author, redirect author pages to main page, etc…
    Search pages are noindex by default and 404 are not indexed if they return a 404 error.
    Paged content for categories and tags are noindex if you select noindex in Yoast, Paged content for the main (https://your-domain.com/page/xx) are index but not included in the sitemap generated by the plugin.

    #2174517
    steven

    I don’t want to use Yoast or Rankmath or any other plugin: they all slow down and stop the site from working. It crashes every time I try.

    Can you confirm that the code I have added will no-index the unwanted content, and NOT touch posts and pages?

    Thanks for your reply.

    #2174540
    Longinos

    Hi
    Well…. you can use is_archive(), this includes author, categories, tags, dates…
    and maybe add is_attachment() (these pages are for show media files in the media library)
    And the _e() function is for translate the text, don´t print it in the html code.
    The meta tags must be set in the header so better do some action in wp_head.
    Some like:

    function my-noindex(){
    if( is_author() | is_date() | is_paged() | is_tag() | is_404() | is_search()) {
    echo ‘<meta name=”robots” content=”noindex, follow” />’;
    } 
    add_action('wp_head','my-noindex');

    and put this code in the functions.php of your child theme.

    You can view contitional tag here https://codex.wordpress.org/Conditional_Tags

    #2174810
    Ying
    Staff
    Customer Support

    Hi Steven,

    As Longinos said, the theme can’t control how or whether the index pages are generated, it’s controlled by WordPress.

    The function should work, and there’s an easier way to do this.

    1. Create a hook element.

    2. Paste this HTML code to the hook element:
    <meta name="robots" content="noindex" />

    3. Choose wp_head as hook.

    3. Then choose location accordingly, in your case, all_archives might be the one.

    #2306461
    Michael

    Hi Ying,

    I want to prevent a staging site from being indexed and will use the head hook meta tag.

    Once that’s in the PHP file using the hook element, is it easy to remove just by going back into the hook, deleting and resaving it?

    Thanks

    Michael

    #2306469
    Fernando
    Customer Support

    Hi Michael,

    Yes, you can just set the hook element to draft when you want it disabled.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.