Site logo

Archived topic

Displaying pages and posts on author page

5 replies · Started by Rani on July 11, 2019

Viewing posts 1–6 of 6

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 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 :)

This archived topic is closed to new replies.