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!

scott hartley

About the author

Scott is a web performance geek, lover of all things coffee, and avid video game player. His WordPress work delves into web performance, web security, and SEO.

Leave a Comment