skip to Main Content

Snippet: Add Post Types To Author Archives

By default WordPress author archives only display posts from the standard post type, however, you can easily tweak things via your child theme to include any post types you want in the author archive. The snippet below shows how you may include a "portfolio" post type in the author archives. Simply add your post types you want included to the array.

// Add Custom Post Types to Author Archives
add_action( 'pre_get_posts', function($query) {
	if ( $query->is_author && $query->is_main_query() ) {
		$query->set( 'post_type', array( 'post', 'portfolio' ) ); // include your types in the array here
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend WPCode)
Back To Top