[Support request] Display Pages on Author Archives

Home Forums Support [Support request] Display Pages on Author Archives

Home Forums Support Display Pages on Author Archives

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1598895
    Josh

    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

    #1599087
    Elvin
    Staff
    Customer Support

    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.

    #1599733
    Josh

    Thanks Elvin. Where exactly do I put this PHP snippet? On the archives.php page? Or the functions.php page?

    #1599765
    David
    Staff
    Customer Support

    Hi there,

    this article explains how to add PHP:

    https://docs.generatepress.com/article/adding-php/

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