Show Articles from All Custom Post Types on WordPress Author Page

WordPress

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 Managed WordPress Hosting

WPEngine is the best and most secure managed 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.

Tags: | |

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.


Similar Articles

0 Comments

Leave a comment

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.

WordPress Maintenance Service

Struggling to manage your WordPress website? We can handle everythin so you can focus on running your business.

Contact Us
© 2022 The WP Guides Developed By Deepanker

The WordPress® trademark belongs to the WordPress Foundation. The WP Guides is not affiliated with or endorsed by the WordPress Foundation.