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 have created a custom author's page that list the title of their posts. but the problem is i can't get the pagination to work if it's beyond the set post per page value. i have used get_posts() to it's custom loop.

                    $ppp = 5; //set my custom number of post to appear
                    $uid = $curauth->ID;
                    $args = array(
                                    'numberposts' => $ppp,
                                    'author' => $uid

                    $authorposts = get_posts($args);
                    if ( count( $authorposts ) > 0 ) {               

                        foreach ( $authorposts as $post ):  setup_postdata($post)            ?>

                                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" class="authorpostlink"><?php the_title(); ?></a>
                                <?php the_excerpt(); ?>
                    <?php endforeach;  ?>
                        <div class="post-nav">
                            <div class="previous"><?php previous_posts_link('&lsaquo; Previous Page') ?></div>
                            <div class="next"><?php next_posts_link('Next Page &rsaquo;') ?></div>
                    } else {
                        echo '<p>No articles by this user</p>';

This should display 5 post with it's title and it's excerpt by the author,....but the rest of the author's posts isn't paginated what it paginates is the whole number of post on the blog.

share|improve this question
You have been flagged for possibly duplicate accounts wordpress.stackexchange.com/users/5443/ven wordpress.stackexchange.com/users/5475/ven Please consider registering on site (or using some OpenID to login) and asking moderators to merge extra accounts so it is more convenient both for you and community. :) TIA – Rarst May 28 '11 at 19:59

Put the following code in your functions.php file.

function limit_posts_per_page() {
if ( is_author() ) // you can limit other pages as well ( i.e. is_archive() ), if need be.
    return 5;
add_filter( 'pre_option_posts_per_page', 'limit_posts_per_page' );

Make sure your using the author.php template, otherwise it wont work. Please have a look at twentyten's author.php for best practices.

share|improve this answer
And even more important: don't call get_posts() or query_posts() yourself in the template file. Modify the standard query that WordPress will do anyway, using the method VicePrez explained here or using the pre_get_posts action. – Jan Fabry May 17 '11 at 15:26
THANK YOU VERY MUCH @VicePrez – Steffi Jan 3 '12 at 19:06
No problem @Steffi – VicePrez Jan 4 '12 at 6:49

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.