Disable Author Archives in WordPress
Home » WordPress » How to Disable Author Archives in WordPress

How to Disable Author Archives in WordPress

How to Disable Author Archives in WordPress – Disabling author archives in WordPress can be particularly useful for websites that are managed by a single author or for those looking to streamline their URL structure and prevent duplicate content issues.

Author archives typically list all posts published by a specific user and can sometimes be redundant or unnecessary.

Understanding the Impact of Disabling Author Archives

Disabling author archives helps simplify the site structure and can improve SEO by eliminating potentially thin or duplicate content pages.

It also enhances privacy by not publicly listing all posts associated with a particular author, which is especially important for single-author blogs.

Methods to Disable Author Archives

You can disable author archives by either using a plugin, which is user-friendly and reversible, or by adding custom code to your site for a more permanent solution.

Both methods can be implemented without significant technical challenges.

How to Disable Author Archives in WordPress Using a Plugin

A plugin like “Yoast SEO” can manage author archives settings easily. This is a great option if you’re already using the plugin for SEO purposes.

Steps to disable author archives with Yoast SEO:
  1. Go to SEO > Search Appearance in your WordPress dashboard.
  2. Navigate to the ‘Archives‘ tab.
  3. Find the ‘Author archives settings‘ and toggle the ‘Enabled‘ option to ‘Disabled‘.
  4. Save changes.

This method not only disables the author archives but also redirects any traffic that might reach these URLs to your homepage or another specified address, improving the user experience and SEO.

How to Disable Author Archives in WordPress Using Custom Code

For those who prefer not to use additional plugins or desire a more direct approach, adding custom code to disable author archives is effective.

This can be done via the theme’s functions.php file, a WordPress child theme, or using a site-specific plugin to keep your changes safe through updates.

Option 1: Using the Child Theme’s functions.php File

Inserting the following code into your child theme’s functions.php file will disable author archives:

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

This code checks if an author archive page is being requested and, if so, sets it to return a 404 error, effectively disabling the archive.

But if you want to redirect to other page instead of giving 404 error, you can add the following code instead:

add_filter( 'author_link', function ( $link ) {
    return home_url( 'about' );
});
 
add_action( 'template_redirect', function () {
    if ( is_author() ) {
        wp_redirect( home_url( 'about' ) );
        exit;
    }
});

Just change the about to another page slug, like contact, shop, etc.

Option 2: Using a Site-Specific Plugin for Custom Code Snippets

Using a site-specific plugin like “Code Snippets” for managing custom code ensures that your changes remain intact through theme updates and changes.

  1. Install the “Code Snippets” plugin from the WordPress plugin repository.
  2. Activate the plugin and navigate to Snippets > Add New.
  3. Paste the same code snippet into the new snippet area.
  4. Name your snippet (e.g., “Disable Author Archives“), save it, and activate it.

Wrapping Up

Disabling author archives can be beneficial for improving both the privacy and SEO of your WordPress site. Whether you opt for a plugin or a direct coding approach, the process is straightforward and can significantly simplify your website’s structure.

Each method offers specific advantages, allowing you to choose based on your site’s needs and your comfort with WordPress administration.

Similar Posts