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 some problem with page pagination using wp-pagenavi, i'm using this query:

$myposts = query_posts( array( 'showposts' => 10, 'paged' => get_query_var('paged') ) );;

i would that had 10 posts per page, in fact, it pages, but it only pages with 5 posts per page, i have 18posts, and cant have success to paginate.

At Configurations > Reading > Posts per page: 10.

What can be my problem?

code: http://pastebin.com/TC7eBuFh

share|improve this question
Can you show us more code than this? The query_posts() function is not recommended, so most of us wouldn't use it if someone pointed a gun to our head. We need to see more code so we can run it to test it for you. – Charles Clarkson Sep 24 '13 at 16:34
@CharlesClarkson code added. – Matheus Silva Sep 24 '13 at 17:42
Thanks. The code in the link has showposts set to 5, not 10. – Charles Clarkson Sep 24 '13 at 17:54

Try this:

<?php get_header(); ?>

<div id="content">
    <div id="page">

global $post, $paged;

if ( get_query_var( 'paged' ) )
    // On a paged page.
    $paged = get_query_var( 'paged' );

else if ( get_query_var( 'page' ) )
    // On a "static" page.
    $paged = get_query_var( 'page' );

// Default.
    $paged = 1;

$myposts = query_posts( array(
    'posts_per_page' => 10,
    'paged' => $paged,
) );
share|improve this answer
seens this doent make any difference, try this image, it paged only 5 itens again =/ i227.photobucket.com/albums/dd243/PlayMa256/… – Matheus Silva Sep 24 '13 at 22:14
Try using the get_posts() function in place of the query_posts() function. Replace $myposts = query_posts( array( with $myposts = get_posts( array(. – Charles Clarkson Sep 25 '13 at 1:48
its impossible, it keeps paginating only 5 posts, i have 18, i was to paginate 10 at first page, and 8 at second....GOD WHY! – Matheus Silva Sep 25 '13 at 16:37

Try this:

    $args = array( 'posts_per_page' => 5, 'paged' => get_query_var('paged') );
    $query = new WP_Query( $args );
    if ( $query->have_posts() ):
       while( $query->have_posts() ): $query->the_post();
       // Template loop here
    // No posts with query
    if( function_exists( 'wp_pagenavi' ) ) { wp_pagenavi( array( 'query' => $query ) ); }
share|improve this answer
A comment explaining what the code does and how it answers the question is very useful and would make your answer much better. – cybmeta May 15 '15 at 16:24

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.