How to Hide or Disable Archives in WordPress

Posted on

WordPress generates all of its URLs on the fly. Not just posts and pages, but also a lot of other dynamic content that keeps changing depending on the situation. In fact, if you’ve been blogging for a long while over several years, you will have a separate archive page for every month of every year, and for every author on your blog. Not to mention all the posts belonging to a specific category or tag. While some of these additional pages are useful for allowing visitors to browse your old blog posts and uncover lost treasures, they can also be a nuisance that detract from the overall experience.

Say for example a person conducting a search on Google is presented with a long list of databased archives – it’s happened quite often with me. Instead of showing individual posts, the search results will serve up pages containing only a snippet of the actual article. Another example of an un-optimal state of affairs is if you’re the only author on your blog, then your “author page” will not be any different from your blog homepage!

In this article, we look at how to do two things – how to disable indexing for various types of archive pages without touching robots.txt, and how to remove these pages from your blog altogether so that users are redirected back to your homepage whenever they type in the URL of some kind of archive.

Hiding Archives via a Plugin

I’ve already written about earlier how to disable the indexing of archive based pages by inserting the relevant HTML code into the header. However, if you already have the plug-in called “SEO Ultimate” installed, I recommend using that instead. The reason why I use this particular plug-in is that it combines the functions of several plug-ins into one, thus reducing the headache of management as well as decluttering my WordPress plug-in page.

Once you’ve installed the SEO Ultimate plugin, go to the “Modules” link under the new “SEO” in the WordPress administration dashboard. This will bring up a number of modules that you can enable or disable depending on your preferences. Scroll down to find the “Meta Robots Tag Editor” as shown here:

meta robots tag editor

Clicking this will allow you to configure the indexing of every page on your blog. If you only want to disable indexing for a few posts for example, that’s possible under the “Posts” tab. However, if you want to do so for an entire category of pages, click the “Defaults” tab.

disable indexing of archives

Over here, you see a list of all the different types of pages for which you can disable indexing. In this example, I’ve opted to take out the author archives, the category archives, and the date-based archives. While these can be useful for users to navigate the site, I’m not interested in having them show up as part of my search results.

Disabling these Pages Entirely

What if you want to get rid of them altogether instead of just deleting them from the search results? Perhaps you’re designing your business website using WordPress and the concept of archives is a redundant one. For whatever reason, merely removing the visible links to the archive pages isn’t enough. These can be accessed directly via URLs. So we’re going to have to redirect all of these to our homepage. We can do that using the following code in our “functions.php”:

function redirect_to_home( $query ){
    if(is_date() ) {
         wp_redirect( home_url() );
         exit;
     }
}
add_action( 'parse_query', 'redirect_to_home' );

As you can see, we hook into the action called “parse_query” which points WordPress to our own custom “redirect_to_home” function. In this particular example, I’ve chosen to redirect all date-based archives to the homepage using the conditional function “is_date()”. If you want, you can expand this to include any archive page using “is_archive()” instead. Keep in mind that this will disable every single archive including categories, tags, and author pages. If you only wish to disable auto pages, you can use the “is_author()” function.

To get a comprehensive list of every single conditional tag available, you can consult the WordPress Codex. They give you a lot of power in deciding whether or not you wish to get rid of specific WordPress pages altogether.

3 Comments on “How to Hide or Disable Archives in WordPress”!

  • Thanks for help

  • Thanks very much Bhagwad, for your article.

    I have a Calendar widget showing links to all the post pages.
    I followed your article and, I’m able to redirect theses links to my home page.
    But i wish to deactivate these links from my calendar, it will be just a simple calendar, with the current day selected.

    I’m actually using the Default wordPress Calendar Widget, with Appointement Blue Theme.
    can you help me please?

  • Thanks for the article Bhagwad. One issue though, if I’m adding in a redirect to my functions.php file for “is_archive”, that will affect back-end navigation using the wp-admin platform. Any way around this issue?

Leave a Reply

Your email address will not be published. Required fields are marked *