[Support request] Show Pages Written By Author on Author Page

Home Forums Support Show Pages Written By Author on Author Page

  • This topic has 3 replies, 2 voices, and was last updated 2 months ago by David.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1377213
    Aditya

    I want to show pages written by the author on their author page, How can I do that, currently it only shows post written by him.

    #1377659
    David
    Staff
    Customer Support

    Hi there,

    you can include Pages in the author archive with a snippet like so:

    function author_archive_include_pages($query) {
        if ($query->is_author) 
            $query->set( 'post_type', array('post', 'page') );
        
        remove_action( 'pre_get_posts', 'author_archive_include_pages' );
    }
    
    add_action('pre_get_posts', 'author_archive_include_pages');

    However, Pages don’t have the meta that posts do and they won’t have the standard formating of posts….

    Why not just use Post instead of Page ?

    #1379472
    Aditya

    Hi David,

    So basically we created a pages which will help us to get sale and post will work as pillar pages, Well can you please help me where exactly i need to paste this code?

    Do i need to create a hook and paste it there or what?

    #1379556
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.