WordPress is a popular CMS which we can use to write blog posts for our readers. All those blog posts have to be written by someone. The posts will also have some tags and categories attached to them.
WordPress has a feature where you can see all the posts published under a certain tag or category. Similarly, you can also see all the posts written by a particular author by visiting a special link called the author page.
Let’s say someone is reading a blog post written by a particular author and they liked it. They might want to read more posts from that author. In this case, they can simply click on the author name and get to the author page. It is evident that author pages can be useful for driving up reader engagement.
However, you might want to disable them in certain situations, such as a website having only one author, to prevent SEO issues related to content duplication, or for a bit of additional security.
In this tutorial, I will show you how to disable author pages in WordPress.
Understanding the Template Hierarchy for Author Pages
A WordPress theme contains different template files that it uses to display a variety of content such as author pages. Which template files from a theme are used to display a specific type of content depends on the query strings and the template hierarchy rules.
In the case of author pages, WordPress looks at the following list to determine the right template file to use:
-
author-{nicename}.php: The
nicename
here is basically a sanitized version of the author’s username. If thenicename
was monty, WordPress would first look for the file author-monty.php. - author-{id}.php: This template page is based on the author ID. If the author ID is 16, WordPress would look for the file author-16.php. WordPress looks for this file if there is no specific file with the nicename.
- author.php: This is a general template file applicable to all authors if no author-specific file is provided.
- archive.php: WordPress looks for this file next if there is no author.php file available.
- index.php: WordPress will finally use the index.php file if it doesn’t find any other suitable template file.
Here is a screenshot from a WordPress website which contains the author.php page in its theme.
Since having an index.php or index.html file is a requirement for WordPress themes, the use of template hierarchy means that WordPress is going to find a way to display author pages and their content in the end. You cannot simply delete the author-monty.php or author.php file to disable author pages!
WordPress URLs for author pages will look something like this:
1 |
https://website.com/author/username/ |
Whenever someone tries to visit that page, WordPress will try its best to load the appropriate template file. This also means that you will still end up loading the author archives using the index.php file if nothing more appropriate is available.
With all this in mind, let’s see how we can disable WordPress author pages.
Disabling Author Pages With Plugins
Disabling author pages in WordPress basically means either redirecting anyone who requests an author page to the homepage or returning the 404 status code.
In this section, I will show you how to use plugins to disable author pages.
Using a Specialized Plugin
The Disable Author Archives plugin in the WordPress plugin directory goes with the latter option and returns a 404 error if anyone tries to redirect the authors. It is a simple and lightweight plugin that doesn’t require any special configuration from your end. It starts disabling the author pages as soon as you activate it.
Here is the result that I get when I visit the author page after activating the plugin:
You might see something different based on the 404.php page active on your website. If you don’t see the 404 page after activating the plugin, you should consider clearing your cache.
Using SEO Plugins
Quite a few SEO plugins also offer the option to disable author pages. I will use the Rank Math SEO plugin as an example here.
Once you have installed and activated the plugin, you need to navigate to Rank Math > Titles & Meta > Authors from the WordPress admin dashboard. This will take you to the following configuration options:
Click on the Disabled button and then the Save Changes button. Try reloading the author page now, and you’ll be redirected to the website’s homepage.
What’s the Difference?
The primary difference between using a specialized plugin and SEO plugins for disabling author pages is the way in which they handle existing and non-existing author pages.
For example, let’s say someone visits the URL https://website.com/author/none-exists/ in their browser. In this case, both the SEO plugin and the specialized plugin will show the 404 error.
However, if someone visits the URL https://website.com/author/exists/ in their browser, the SEO plugin will redirect to the homepage, while the specialized plugin will still show the 404 error.
You can use whichever plugin you like based on your preferences.
Prevent Author Pages From Getting Indexed
Sometimes, people don’t actually want to disable author pages but simply don’t want them indexed in search engines. This is usually done to prevent any SEO-related issues due to duplicated content, while still providing a better user experience to readers.
Different SEO plugins can help you prevent author pages from getting indexed without ever disabling them. Going back to the Rank Math SEO plugin, you could navigate to Rank Math > Titles & Meta > Authors and then Enable author archives.
This will show a bunch of options related to author pages.
At the top is the Author Base, which allows you to change the URL used to access the author page. WordPress uses the following URL format by default:
1 |
https://website.com/author/username/ |
You can update the value of the author base so that the new URL for the author page becomes:
1 |
https://website.com/contributor/username/ |
Please note that this will not automatically redirect URLs with author base to contributor base. Using the author base now will result in a 404 error instead.
Activate the checkbox option titled Author Robots Meta as this will allow you to provide custom robot meta tags for the author pages.
The only thing left to do now is select the meta tags that you want to activate on the author page. We have just selected the No Index meta tag here.
Disable Author Pages Using Code
Writing your own code is your best bet if you don’t want to download a new plugin simply to disable author pages and your SEO plugin doesn’t offer this functionality.
All we need to do here is write a function attached to the template_redirect
action that will redirect users to the homepage if they are trying to visit an author page.
Place the code below inside your functions.php file, and you will be good to go.
1 |
function monty_redirect_author_page() { |
2 |
global $wp_query; |
3 |
|
4 |
if (is_author()) { |
5 |
wp_safe_redirect(get_option('home'), 301); |
6 |
exit; |
7 |
}
|
8 |
}
|
9 |
add_action('template_redirect', 'monty_redirect_author_page'); |
We use the is_author()
function to check if the current query is asking for an author archive page. After that, we use the wp_safe_redirect()
function to redirect visitors to the homepage.
Final Thoughts
In this tutorial, we learned about different techniques to disable author pages on your website. We began by learning about template hierarchy and how simply deleting the author.php file isn’t a good idea.
You can use specialized plugins and investigate the SEO plugin that you have installed to see if it gives you the option to redirect author pages. It’s also possible to add a simple code snippet to your theme’s functions.php file to handle the redirection of author pages.