After searching for 2 days I still cant find a solution on this problem. There is no content on the second page of posts. I cant figure out what I'm doing wrong. I'm building my own theme and using the twentyeleven_content_nav, version 3.3.1 of WordPress.

I got a page called news and on that page there is a sidebar with a list over previous months. When I push January 2012, for example, WordPress uses archive.php and I've managed to print the 5 latest news for that month and add pagination with both prev/next-links and numbers in between. But why aren't there any posts on the second page? I don't understand what happens when page 2 is created or what file it uses for its content. Please, help!

Regards, Bellisia

<?php
    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

    $args = array(
    'posts_per_page' => 5, 
    'paged' => $paged );

    $wp_query = new WP_Query( $args );

    $wp_query->query_vars[ 'paged' ] > 1 ? $current = $wp_query->query_vars[ 'paged' ] : $current = 1;

    $pagination = array(
        'base' => @add_query_arg( 'paged', '%#%' ),
        //'format' => '',
        'showall' => false,
        'end_size' => 4,
        'mid_size' => 4,
        'total' => $wp_query->max_num_pages,
        'current' => $current,
        'type' => 'plain'
    );

    if ( $wp_rewrite->using_permalinks() )
        $pagination[ 'base' ] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );

    if ( !empty( $wp_query->query_vars[ 's' ] ) )
        $pagination[ 'add_args' ] = array( 's' => get_query_var( 's' ) );

    if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>  

    <h2 class="entry-title">
        <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
            <?php the_title(); ?>
        </a>
    </h2>

    <span class="date"><?php the_time('Y-m-d')?></span>
    <p><?php print get_the_excerpt();?></p>

<?php 
    endwhile; endif;
    echo '<div class="pydPaging">' . paginate_links( $pagination ) . '</div>';  
?>
link|improve this question
Can you provide us with some code sample of your 'loop' or how you are displaying the posts currently? – Jared Jan 19 at 13:02
Or your website so we can see what you mean? – Kimberley-Marie Sklinar Jan 19 at 14:34
1  
Sorry about that, edited the question and added the code :) – Bellisia Jan 19 at 15:20
I found the solution here: esujay.com/… – Bellisia Jan 23 at 14:56
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.