How To Disable Author Archive Pages Without A Plugin

Home » WordPress Tutorials » How To Disable Author Archive Pages Without A Plugin
  • disable author archive pages

How To Disable Author Archive Pages Without A Plugin

WordPress has a lot of cool archives built into the default system. For example, the following each have their own archive:

  • Each Taxonomy
  • Search
  • Author Archives

For single author websites, author archives do not do much good; as they will look just like the homepage. I will note, author archives can be disabled in Yoast SEO, and there may be a more efficient way of doing this, but this is what has worked for me.

/* Disable Author Pages (Archives) */

function sertmedia_disable_author_archives() {

if (is_author()) {

global $wp_query;
$wp_query->set_404();
status_header(404);

} else {

redirect_canonical();

}

}
remove_filter('template_redirect', 'redirect_canonical');
add_action('template_redirect', 'sertmedia_disable_author_archives');

This isn’t the largest snippet and it’s quite efficient. Essentially, if you are on an author page then it will return a 404. This is a quick fix to remove pages without having to implement meaningless redirects. This can be added to the following places:

  • functions.php file of a child theme

You can change this code to do a 301 redirect to your homepage or any number of things, but this is a quick and simple way to disable author archive pages without a plugin.

Do you have any questions about this implementation? If you need assistance or have a question feel free to ask me in the comments below and I will make sure to get back to you!

By |2018-12-02T16:43:10+00:00December 1st, 2018|Categories: WordPress Tutorials|Tags: |0 Comments

About the Author:

Scott Hartley is a WordPress Developer who focuses on website performance optimization, SEO, and security. He can't tell you what a color wheel is but he knows the intricacies of making a website load quickly.

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.