• Resolved jorgemarsa

    (@jorgemarsa)


    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('&laquo; ART&Iacute;CULOS ANTERIORES') ?></div>
    			<div class="alignright"><?php previous_posts_link('ART&iacute;CULOS POSTERIORES &raquo;') ?></div>
    	</div>
    </div>
    
    	<?php else : ?>
    
    		<h2 class="pagetitle"><?php _e('Resultados de la b&uacute;squeda'); ?></h2>
    		<?php _e('No aparecen resultados con las palabras utilizadas'); ?>
    
    		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    
    	<?php endif; ?>
    
    </div>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jorgemarsa

    (@jorgemarsa)

    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:

    http://wordpress.org/support/topic/57912#post-312858

    Thread Starter jorgemarsa

    (@jorgemarsa)

    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; ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘navigation broke in posts in two columns’ is closed to new replies.