• I just figured out how to make pagination work for my articles’ page, following the last answer in:
    https://stackoverflow.com/questions/14364488/wordpress-pagination-next-posts-link-on-custom-wp-query-not-showing

    So after that, my pagination was working, but my get_sidebar() stopped working.
    In this sidebar I was displaying last entrances (using the widget) and the most popular posts, using WordPress Popular Posts. These two blocks are not displayed anymore and I wonder if there is anything I am doing wrong.

    The code I used is the following:

    <div class="XX">
        <?php
        global $wp_query, $paged, $copy_query;
        if( get_query_var('paged') ) {
            $paged = get_query_var('paged');
        }else if ( get_query_var('page') ) {
            $paged = get_query_var('page');
        }else{
            $paged = 1;
        }
        $copy_query = $wp_query;
        $wp_query = null;
        $args = array(
            'category_name' => 'XX',
            'posts_per_page' => 5,
            'paged' => $paged
        );
        $wp_query = new WP_Query();
        $wp_query->query( $args );
        while ($wp_query->have_posts()) : $wp_query->the_post();
        ?>
        <div class="XXX">
            <h2><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
        </div>
        <div class="YYY">
        <?php
        the_excerpt();
        n_clear();?>
        </div>
        <div class="ZZZ">
            <p><a href="<?php the_permalink(); ?>">Something</a></p>
        </div>
        <?php endwhile; ?>
    	</div>
    	<div class="navigation">
    		<div class="nav-previous"><?php previous_posts_link(); ?></div>
    		<div class="nav-next"><?php next_posts_link($printposts->max_num_pages);     ?></div>
    	</div>
    	<?php wp_reset_query();
    	$wp_query = $copy_query;?>
        </div>
        <div class="articles-sidebar">
    	<?php get_sidebar(); ?>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Incompatibilities between get_sidebar and pagination’ is closed to new replies.