The default WordPress author archive page template displays only default post types. The custom posts are not included. The following WordPress code snippet will help you to include WordPress custom post types to author archive page.

Add the following snippets to your WordPress theme functions.php file:

add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {

	if ( is_author() && $query->is_main_query()) {
		$query->set( 'post_type', array( 'post', 'post_type1', 'post_type2' ) );
	}
	return $query;
}

Save the changed functions.php and visit your your WordPress author archive.

Bibhudatta

She loves coding for web and working with Microsoft Technologies. She has developed enterprise applications with B2B and B2C business models for worlds leading Financial and Retail chain market.

Related Articles

Join The Discussion

Please note: We reserve the right to delete comments that contains snarky remarks, offensive or off-topic. To know more read our comments policy.