• jobmeer

    (@jobmeer)


    For the last days I tried to get a loop over 2 columns. All the tutorials I’ve have find do provide a loop code but none of theme work with paged pages.

    I have a left column that have to show 5 posts (from a certain category) and a right column that have to show the next 5 posts. I do not want to css split the posts but want a multiple loop that works with paged pages. So the next paged have to show the next 10 (5×5) post etc. etc.

    Does anyone have a idea? I really appreciate your comment.

Viewing 1 replies (of 1 total)
  • Thread Starter jobmeer

    (@jobmeer)

    I have create a code that allow 2 loops and not duplicate the posts, but it is still not working for the next page ($paged). Here the code:

    <?php get_header(); ?>
    <?php get_sidebar(); ?>
    
    	<?php /* Left Column
    -------------------------------------------------------------------*/?>
    	<div id="left-column">
    
    	<?php if (have_posts()) :
    	$count = 0;
    	$saved_ids = array();
    	while (have_posts()) : the_post(); ?>
    	<?php $count++; ?>
    	<?php $saved_ids[] = get_the_ID(); ?>
    
    	<?php if ($count <= 5) : {
     	$saved_ids[] = get_the_ID();?>
    
    	<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    	<?php the_excerpt(); ?>
    
    	<?php } endif; // End if ?>
    	<?php endwhile; 
    
    	else: ?>
    	<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    	<?php endif; ?> 
    
     	<?php posts_nav_link(); ?>
    
    	</div>
    
    <?php /* Right Column
    -------------------------------------------------------------------*/?>
    	<div id="right-column">
    
    	<?php if (have_posts()) :
    	query_posts(array(
    	'post__not_in' => $saved_ids,
    	));
    
    	while (have_posts()) : the_post(); ?>
    
    	<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    	<?php the_excerpt(); ?>
    
    	<?php endwhile; 
    
    	else: ?>
    	<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    	<?php endif; ?> 
    
    	</div> 
    
    <?php get_footer(); ?>

    Does anyone have a idea how to fixed the paged problem in this code?

Viewing 1 replies (of 1 total)
  • The topic ‘Paged loop over 2 columns’ is closed to new replies.