• Here’s what I have:

    <?php
    query_posts( 'tag=featured&orderby=modified&order=ASC' );
    $inc = 0;
    while ( have_posts() ) : the_post();
    $inc++; ?>
    	<li><a href="#slide<?php echo $inc; ?>" id="slide<?php echo $inc; ?>"><?php echo $inc; ?></a>
    <?php
    endwhile;
    wp_reset_query(); ?>

    What I’d like it to output is:

    <li>
    	<h3>Article Title</h3>
    	<p>Article summary</p>
    	<h3>Article Two Title</h3>
    	<p>Article Two summary</p>
    </li>

    How can I get the while loop to output one set of li tags around two posts?

    What I need is to have each set of two posts as a slide in a javascript slider. Each time the user clicks the arrow to move the slider, a new set of two appears.

Viewing 2 replies - 1 through 2 (of 2 total)
  • It should be as easy as this (note.. I haven’t tested this, so I’m not 100% sure of it working):

    while ( have_posts() ) : the_post();
        echo '<h3>'.the_title().'</h3>';
        echo the_exerpt();
    
        the_post();
    
        echo '<h3>'.the_title().'</h3>';
        echo the_exerpt();
    <?php

    That will give you two posts for each iteration of the while() loop. And then you can wrap anything else around the posts that you want to.

    Thread Starter biffwebsterjr

    (@dirtyfrank)

    That was exactly right. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Need two posts in the while loop, not just one.’ is closed to new replies.