Disable creation of archives for tags completly

#606775
  • Resolved Anonymous
    Rank Math free

    Hi!
    I was wondering if there is a chance that I can disable the creation top archive pages for tags completely?

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you so much for getting in touch.

    At the moment, our plugin doesn’t have the ability to disable tag archives.

    You may try the code below to disable the tag archives:

    function disable_tag_archives() {
      unregister_taxonomy_for_object_type('post_tag', 'post');
    }
    add_action('init', 'disable_tag_archives');

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

    If the code above doesn’t work, you may try this instead:

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

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

    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 1 replies (of 1 total)

The ticket ‘Disable creation of archives for tags completly’ is closed to new replies.