Can Rank Math disable archives?

#529961
  • Resolved Dre
    Rank Math free

    Is there a setting to completely disable post category archives, post date archives and post tag archives? I know you can disable author archives, but how o disable the others? Yoast allows this…

Viewing 15 replies - 1 through 15 (of 17 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    In Rank Math, you can disable the date archives post type in on your WordPress dashboard > Rank Math > Titles & Meta > Misc Pages

    Date

    Here’s a link for more information:
    https://rankmath.com/kb/titles-and-meta/#date-archives

    Please note that some options are only available when you enable the Advanced Mode in Rank Math. If it’s not showing, you must have chosen to use Easy Mode. Please follow the steps in this link to switch to Advanced Mode:
    https://rankmath.com/kb/advanced-mode/

    Hope that helps.

    Thank you.

    Dre
    Rank Math free

    Hi,
    thanks, but I am talking about category and tag archives as well. Also, I don’t want the author and date archibes to be redirected to the homepage but zo 404 instead, because it is not recommended to redirect a bunch of pages to the homepage by Google. So please let me know how to fully disable all caegory archives, tag archives, date archives and author archives and redirect them to 404.

    Hello,

    You can use this action code to set your category and tag archives to 404. Please refer to this PHP code:

    function disable_category_archives() {
        global $wp_query;
    
        if (is_category() || is_tag()) {
            $wp_query->set_404();
            status_header(404);
        }
    }
    
    add_action('template_redirect', 'disable_category_archives');

    You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Dre
    Rank Math free

    Hi,
    thanks, but I need to know how to do this for tag annd ctegory archives as well! Rank Math redirects to homepage and this is NOT recommended by Google, so pease let me know how to copletely disable ALL archives and set them to 404, including author and date.

    Hello,

    The filter my colleague shared above does work for tag and category archives and throws 404. To do the same with all archives, please try applying the following filter to your site:

    function disable_archives() {
        global $wp_query;
    
        if (is_archive()) {
            $wp_query->set_404();
            status_header(404);
        }
    }
    
    add_action('template_redirect', 'disable_archives');

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    Dre
    Rank Math free

    Hi,
    but this will even set 404 for product categoris, which I need to keep enabed. Also, when disabling autor and date archive in Rank Math settings and then plaing this code on top, it would be two redirections to differnt pages – not recommended!

    Nigel
    Rank Math business

    Hello,

    The code snippet we shared earlier should work:

    
    function disable_category_archives() {
        global $wp_query;
    
        if (is_category() || is_tag()) {
            $wp_query->set_404();
            status_header(404);
        }
    }
    
    add_action('template_redirect', 'disable_category_archives');
    

    If it is redirecting to your homepage, you may have the 404 to homepage redirect fallback turned on. You can turn off this setting by going to your WordPress Dashboard > Rank Math > General Settings > Redirections, change the setting to “Default 404” and click “Save Changes”.

    Hope that helps. Please let us know if you have questions.

    Dre
    Rank Math free

    Hi,
    you are not understanding wat I am saying I think: I need to set date and author archive to 404 as well (and noindex, nofloow, noarchive them) but if I do that through the pugin opions the redirect will go to homepage!

    Nigel
    Rank Math business

    Hello,

    So sorry I missed that. You want date, author, category and tag archives to all go to 404.

    Please enable date and author archives in the Rank Math settings then add this revised filter:

    
    function disable_category_tag_date_author_archives() {
        global $wp_query;
    
        if (is_category() || is_tag() || is_date() ) {
            $wp_query->set_404();
            status_header(404);
        }
    	if ( is_author() ) {
    		status_header( 404 );
            nocache_headers();
            include( get_query_template( '404' ) );
            die();
    	  }
    }
    
    add_action('template_redirect', 'disable_category_tag_date_author_archives');
    

    Hope that helps. Please let us know if you have questions.

    Dre
    Rank Math free

    Thank you! May I ask why the autot archive has a different function?

    Hello,

    You can proceed with omitting the is_author() condition since you already have the option to disable it via our plugin as mentioned here: https://support.rankmath.com/ticket/can-rank-math-disable-archives/?view=all#post-530868

    Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.

    Dre
    Rank Math free

    Hi,
    No, I cannot omit it and also I cannot omit the date function since that sets These pages to my Homepage which is not recommended by Google. That is the whole point of this thread! The archives for date, author, category and Tag should all be no Index, no archive, no follow and Redirects to 404.

    Hello,

    Sorry for the confusion earlier.

    May I ask why the autot archive has a different function?

    You can use the following code also without any additional lines for author archives. It’s up to you.

    function disable_category_tag_date_author_archives() {
        global $wp_query;
    
        if ( is_category() || is_tag() || is_date() || is_author() ) {
            $wp_query->set_404();
            status_header(404);
        }
    }
    
    add_action('template_redirect', 'disable_category_tag_date_author_archives');

    The archives for date, author, category and Tag should all be no Index, no archive, no follow and Redirects to 404.

    Since those pages are being set to 404, you will not need to set noindex additionally. Google will still encounter 404 while crawling and will avoid indexing those archive pages. Here’s what Google should encounter:

    You can also verify using the Rich Results Test tool: https://search.google.com/test/rich-results

    Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.

    Thank you.

    Azuro Digital
    Rank Math pro
    Content AI Expert

    Hi,

    What is the SEO impact of disabling data archives for blog posts? My client has lots of blog posts but they are spread apart across many years. Date archives don’t make sense really as each date only has one post. Should I disable it or keep it for SEO benefits?

    Hello @art5,

    Date Archives are useful only in certain situations, and on most websites, they should be disabled.

    In general, we recommend disabling this because date archive pages usually aren’t very helpful for people looking for specific posts. But it’s up to you to decide what’s best for your site.

    Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 15 replies - 1 through 15 (of 17 total)

The ticket ‘Can Rank Math disable archives?’ is closed to new replies.