Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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):

<ul>
    <?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; ?>
</ul>

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.