By default, author (and other) archives in WordPress display only posts but not Custom Post Type entries.
If you are looking to include items of one or most CPTs in your author archive pages, pre_get_posts
comes to the rescue!
Add this code in your child theme’s functions.php
or as a Code Snippet:
add_action( 'pre_get_posts', 'wpdd_add_cpt_author_archives' );
function wpdd_add_cpt_author_archives( $query ) {
// if this is not the main query or we are in the backend or if the page being viewed is not the author archive, abort.
if ( ! $query->is_main_query() || is_admin() || ! is_author() ) return;
$query->set( 'post_type', array( 'post', 'portfolio' ) ); // replace portfolio with your CPT slug.
}
Replace portfolio
with the slug of your desired CPT.
Ensure that you are in PHP mode i.e, there’s an opening PHP tag before the code.
For Oxygen users: Make sure that Easy Posts or Repeater’s query type is set to default inside the Template that applies to all/author archives.