WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to list 10 last posts of author in author.php template. I used this code:

<?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>

But I can see only the last post of current author. Any help?

share|improve this question
Before that while, there's some QUERY... that's the important part. Please, edit your Question and add this information to it. – brasofilo Nov 1 '12 at 2:32
up vote -1 down vote accepted

The easiest way would be to simply add:

global $query_string;
query_posts( $query_string . '&posts_per_page=-1' );

just before your code so you get :

global $query_string;
query_posts( $query_string . '&posts_per_page=-1' );
while (have_posts()) : the_post(); ?>
     <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
share|improve this answer
Thanks man! :)) – WHiSPER Nov 1 '12 at 5:39
=o query_posts ! – Tom J Nowell Nov 1 '12 at 12:09
@TomJNowell I know and that's way i started my answer with the easiest way ! The preferred way is hooking into pre_get_posts – Bainternet Nov 1 '12 at 13:02
Fair dos, your answer does work afterall =] – Tom J Nowell Nov 1 '12 at 23:46

Rather than clutter your author template, invoke a second query, and use query_posts ( avoid query_posts ), instead use this filter on pre_get_posts instead:

function wpse_show_all_authors($query){
    // if it's an author query
        // put all the posts on page 1
    return $query;

Put it in functions.php and it will work its magic on any and all author templates you have, without needing to modify author.php or execute 2 DB queries instead of 1.

share|improve this answer
Side note: this will add a check on every page load. not like the query_post method which will only effect author archives. – Bainternet Nov 2 '12 at 19:30
I consider an if statement opcode to be orders of magnitude faster than a second DB query and thus worth the cost of a handful of instructions for a simple value comparison, a cost that can be eliminated trivially in even the most elegant of codebases, and that's done by WP Core itself many, many times already. – Tom J Nowell Nov 3 '12 at 1:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.