• Hey,

    I’m using a multiple loop in my index.php page which I copied from here. It works like I want it to but it creates a CSS problem.

    My website is set up like this: link to image

    At least, that’s how I want it to be! Right now the third latest blog is not in a CSS selector which makes it all ugly. I have no idea how I put that third blog in a <div>.

    Here’s my code:

    <?php get_header(); ?>
    <div id="container">
    
    <div id="blog">
    
          <?php $top_query = new WP_Query('cat=3&showposts=1'); ?>
          <?php while($top_query->have_posts()) : $top_query->the_post(); $first_post = $post->ID; ?>
    
          <div class="subject" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></div>
    
          		<?php the_content(); ?>
    
    <div class="meta"><a href="http://www.wakeupsleepyhead.org/about">Nienke</a> | Posted: <?php the_date('F jS, Y'); ?> | <?php the_category(', '); ?> |  <?php comments_popup_link('No Comments', 'One Comment', '% Comments'); ?></div>
    
          <?php comments_template(); // Get wp-comments.php template ?>
          <?php endwhile; ?>
          <br />
    
    <div class="recent">
    <div class="recentpost_left">
            <?php query_posts('showposts=3'); ?>
            <?php while(have_posts()) : the_post(); if(!($first_post == $post->ID)) : ?>
    
                	 <div class="subject" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
              <div class="meta"><a href="http://www.wakeupsleepyhead.org/about">Nienke</a> | Posted: <?php the_date('F jS, Y'); ?> | <?php the_category(', '); ?> |  <?php comments_popup_link('No Comments', 'One Comment', '% Comments'); ?> </div>
    
                		<?php the_excerpt(); ?>
    
                            <?php wp_link_pages(); ?>
                            <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'), 'commentlink'); ?>
    
                <?php comments_template(); // Get wp-comments.php template ?>
    
                </div> <!--div post ends-->
    
            <?php endif; endwhile; ?>

    So basically, my question is: how do I put that 3rd post in a <div> class. I know this is vague, English isn’t my first language and I don’t know much about CSS and PHP.

The topic ‘Multiple loop creates CSS problem’ is closed to new replies.