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.


1 Answer 1


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.

  • 3
    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, 2011 at 15:26

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .