WordPress.org

Ready to get started?Download WordPress

Forums

"Cutting up" the loop - future posts (1 post)

  1. krials
    Member
    Posted 2 years ago #

    Hi! I use the following code for displaying my future posts on top of my page.

    <?php
    			$my_query = new        WP_Query('post_status=future&order=ASC&showposts=5');
    			if ($my_query->have_posts()) {
       			while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
            		<div class="frame">
    
                                 <div class="left">
            		            Coming soon
            		     </div>
    
            		    <div class="right">
    
                                        <div class="post">
                                                 Future post
                                        </div>
    
                                </div>
    
      </div>
    
    <?php endwhile; } ?>

    ----------
    This means that the LEFT-DIV will repeat itself if I have 2 or more future posts. I can put the LEFT-DIV outside the loop, but then it will show even when there is no future posts.

    QUESTION:

    How can I make the LEFT-DIV only appear once if there are future posts, and make the POST-DIV repeat itself inside the RIGHT-DIV if there are more than one future post?

    Thanks in advance!

    -Kristian

Topic Closed

This topic has been closed to new replies.

About this Topic