[Resolved] Displaying pages and posts on author page

Home Forums Support [Resolved] Displaying pages and posts on author page

Home Forums Support Displaying pages and posts on author page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #955301
    Rani

    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

    #955356
    Leo
    Staff
    Customer Support

    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.

    #955656
    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

    #956072
    Tom
    Lead Developer
    Lead Developer

    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' ) );
        }
    } );
    #956148
    Rani

    Hi,
    Yes – That works just great.

    Thanks for the great support, as always!

    Best,
    Rani

    #956311
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.