navigation broke in posts in two columns
-
After several trys, I got a index of 2 posts columns. It seemed to be everything ok, but it didn’t: the navigation broke, I click and click but I always get de first page, I can not go back to de older posts. I think it would be because of the way I code the 2 columns loop, but I am not sure and I do not know how to fix it. Does anybody help me?
This is a extract of my index’s code:
<div id="content"> <div id="col1"> <?php if (have_posts()) : ?> <?php $my_query = new WP_Query('category_name=Sociedad&showposts=8'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?> <?php endwhile; ?> </div> <div id="col2"> <?php query_posts('cat=-2&showposts=9'); // exclude the first category ?> <?php while (have_posts()) : the_post(); ?> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« ARTÍCULOS ANTERIORES') ?></div> <div class="alignright"><?php previous_posts_link('ARTíCULOS POSTERIORES »') ?></div> </div> </div> <?php else : ?> <h2 class="pagetitle"><?php _e('Resultados de la búsqueda'); ?></h2> <?php _e('No aparecen resultados con las palabras utilizadas'); ?> <?php include (TEMPLATEPATH . '/searchform.php'); ?> <?php endif; ?> </div>
-
Instead the tag php next_posts_link, I have tried also with posts_nav_link and previous_post, but I continue without navigation, always in the firs page of my index.php
Basically you’re just running into the problem of query_posts() whacking pagination. Solution:
I really appreciate your help, Kafkaesqui, because this problem was a really pain in the ass to me. Thanks a lot.
I drop here the fixed code to show to columns in the index and with the navigation (older posts) working:
`<div id=”col1″>
<?php if (have_posts()) : ?><?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$my_query = new WP_Query(“category_name=Sociedad&showposts=12&paged=$paged'”);
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>[…]
<?php endwhile; ?>
</div><div id=”col2″>
<?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(“cat=-2&showposts=9&paged=$paged”); ?>
<?php while (have_posts()) : the_post(); ?>[…]
</div>
<?php endwhile; ?>
- The topic ‘navigation broke in posts in two columns’ is closed to new replies.