Archived topic
Display Pages on Author Archives
3 replies · Started by Josh on December 29, 2020
On my author archive pages website.com/author/name/ it shows as "nothing found" since all of the content on my site are pages and not posts. However, once I assign a post to an author then the author page works correctly (although it only shows the one post).
How can I allow the author archive pages to show all pages and posts assigned to each other? Thanks
Hi,
You can try adding this PHP snippet:
add_action( 'pre_get_posts', function( $query ) {
if ( is_author() ) {
$query->set( 'post_type', array('page', 'post') );
}
} );
This should add the pages created by the author. You can add in more post types on the array() if you have custom post types.
Thanks Elvin. Where exactly do I put this PHP snippet? On the archives.php page? Or the functions.php page?