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'm having trouble setting up an author archive. I've come up with a few different loops, but I can't seem to get them quite right. I just want it to list all posts by the current author.

This shows posts by the current author, but only 10 posts (my default number, I guess):

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

This one lists all post by all authors.

<?php global $post;
    $args = array('numberposts' => -1);
    $custom_posts = get_posts($args);
    foreach($custom_posts as $post) : setup_postdata($post); ?>
        <li <?php post_class($custom_classes) ?> id="post-<?php the_ID(); ?>" role="article"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;?>

This doesn't seem that hard. I'm probably missing something obvious. It seems like I need to get the author into a variable and pass it, but I thought that was assumed on the author archive. My attempts to do that just haven't worked.

share|improve this question

your get_posts overrides the normal query_posts query. For this to work properly you should use query_posts and merge in your numberposts setting with the original query, like so:

global $wp_query;
$args = array_merge( $wp_query->query, array( 'numberposts' => -1 ) );
query_posts( $args );

Then you'll no longer need a custom loop either, you could just use a normal loop.

share|improve this answer

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.