• Resolved bobmeier

    (@bobmeier)


    Greetings!
    I’ve recently started using a theme that does not have its own author.php template. I’ve managed to create one using the author template from the Twenty Twelve theme and it works as it should, showing all posts created by the author.

    However, I actually want the author page to show not only the Posts, but also the Pages created by the author. I thought this would be explained for the Twenty Twelve (or Eleven or Ten) Theme somewhere on the Internet but I couldn’t find anything.
    So I’m wondering, is this even possible or does the function to display all Pages from an Author simply do not exist?

    Any help is appreciated!
    All the best,
    Bobmeier

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this in your theme’s functions.php:

    function author_post_and_pages( $query ) {
      // not an admin page and is the main query
      if ( !is_admin() && $query->is_main_query() ) {
        if( is_author() ){
          $query->set( 'post_type', array('post', 'page') );
        }
      }
    }
    add_action( 'pre_get_posts', 'author_post_and_pages' );

    btw:
    consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost.

    Thread Starter bobmeier

    (@bobmeier)

    Took me a while to try it out, but thank you so much – works like a charm!

    I gotta say, I really apreciate the WordPress Community for always providing help so quickly and spot-on!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Twenty Twelve] Display both Posts & Pages on Author Page’ is closed to new replies.