Archived topic
Displaying pages and posts on author page
5 replies · Started by Rani on July 11, 2019
Hi guys,
Thanks for the great theme!
I want to display both posts and pages on author pages.
How can I do that?
Thanks ahead,
Rani
Hi there,
Can you give Patrick solution in the page a shot?
https://premium.wpmudev.org/forums/topic/author-archives-for-custom-post-types-resources
Replace custom_type with page.
Hi Leo,
Thanks for the fast response.
I tried Patrick solution, replacing custom_type with page, as you suggested, but it doesn't seem to work.
Any other suggestions?
Thanks ahead,
Rani
Hi there,
What about this?:
add_action( 'pre_get_posts', function( $query ) {
if ( ! $query->is_main_query() || is_admin() ) {
return;
}
if ( $query->is_author ) {
$query->set( 'post_type', array( 'post', 'page' ) );
}
} );
Hi,
Yes - That works just great.
Thanks for the great support, as always!
Best,
Rani
You're welcome :)