Site logo

Archived topic

Show Pages Written By Author on Author Page

3 replies · Started by Aditya on July 26, 2020

Viewing posts 1–4 of 4

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.

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 ?

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?

This archived topic is closed to new replies.