WordPress.org

Forums

How to make multiple Loop ? (2 posts)

  1. andriuss
    Member
    Posted 6 years ago #

    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>
  2. stvwlf
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic