WordPress.org

Support

Support » How-To and Troubleshooting » How to make multiple Loop ?

How to make multiple Loop ?

  • Hello,

    I want to make 3 columns and put articles, but it loops equally.
    How to make that in every column posts could be different and must work page navigation? Thanks for answers.

    Here is my code:

    <div id="column_01">
    
    	<!-- FIRST LOOP -->
    
    <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
    	  <?php the_content(); ?>
          <?php endwhile; ?>
      <?php else : ?>
          <div>Nothing found</div>
    <?php endif; ?>
    
    </div>
    
    <div id="column_wrap">
    
    	<div id="column_02">
    
    		<!-- SECOND LOOP -->
    <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
    	  <?php the_content(); ?>
          <?php endwhile; ?>
      <?php else : ?>
          <div>Nothing found</div>
    <?php endif; ?>
    
    	</div>
    	<div id="column_03">
    
    		<!-- THIRD LOOP -->
    <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
    	  <?php the_content(); ?>
          <?php endwhile; ?>
      <?php else : ?>
          <div>Nothing found</div>
    <?php endif; ?>
    
    	</div>
    
    </div>
Viewing 1 replies (of 1 total)
  • Hi

    1) see this page
    http://codex.wordpress.org/Template_Tags/query_posts
    Each loop will need a query_posts statement

    2) Use code like this for at least your 2nd and 3rd loops – can use on 1st also

    <?php
            $col2Posts = new WP_Query();
            $col2Posts->query('showposts=5&amp;cat=9');
            while ($col2Posts->have_posts()) : $col2Posts->the_post(); ?>
               <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
           <?php endwhile; ?>

Viewing 1 replies (of 1 total)
  • The topic ‘How to make multiple Loop ?’ is closed to new replies.
Skip to toolbar