Show Articles from All Custom Post Types on WordPress Author Page

Show Articles from All Custom Post Types on WordPress Author Page featured image

Reading Time: 1 min, 59 sec

By default, WordPress author pages only show regular blog posts. If you have multiple custom post types (CPTs) like reviews, tutorials, or portfolios, those posts will not appear on the author page. But you can easily fix this using a simple code snippet. In this guide, I will show you how to show all posts, including custom post types, written by an author on their author archive page.

Also read:

Best WordPress Hosting

Bluehost is one of the best and secure WordPress hosting provider

Why This Happens

WordPress treats each post type differently. The author archive page is only set to fetch the default post type. So, even if an author has published content under custom post types, it will not show up unless we tell WordPress to include it.

How to Fix Show Articles from All Custom Post Types on WordPress Author Page

To show all post types on an author page, we will use the pre_get_posts hook. This hook allows us to modify the query WordPress runs before it gets posts from the database.

Step-by-Step Solution

Open your theme’s functions.php file and paste the following code:

function twg_show_all_post_types_on_author_archive($query) {
if (!is_admin() && $query->is_main_query() && is_author()) {
$query->set('post_type', get_post_types([
'public' => true,
'_builtin' => false
], 'names') + ['post']);
}
}
add_action('pre_get_posts', 'twg_show_all_post_types_on_author_archive');

What This Code Does

  • It checks if you are on the front end and if it is the main query.
  • It then checks if it is an author archive.
  • If yes, it fetches all public custom post types and adds the default post type to the list.
  • Finally, it tells WordPress to include all these post types in the author archive query.

If you only want to include a few specific post types, replace the get_post_types() part with a manual array like this:

$query->set('post_type', ['post', 'reviews', 'videos']);

Replace 'reviews' and 'videos' with the names of your custom post types.

Final Words

That’s it! Now your WordPress author pages will show all posts written by the author, no matter which post type they belong to. This is a small but useful tweak that improves content visibility, especially on sites using multiple post types.

Let me know if you want to filter posts by taxonomy, add pagination, or style the layout differently.

Deepanker profile image

Written by Deepanker

Deepanker Verma is an experienced WordPress developer who has been working on WordPress for more than 12 years. On TheWPGuides, he writes about WordPress, WordPress development, and WordPress plugins.

Leave a Reply

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

Need a Hand with Your WordPress Site?

Don't let technical issues slow you down. Our professional WordPress maintenance service handles updates, security, and performance optimization so you can focus on what you do best: creating content.

Learn More About Our Services