WordPress Query Posts To Show All & Style Each One

I am trying to include every post onto my index page on WordPress and have each one of them be styled with the included CSS. I am able to query all of the posts and have them show up, but only the first post is actually styled. The rest inherit the base h1, h2, p and other generic styles, but they aren’t inheriting the “box” class for each one. All of the information is being thrown into one ‘box’ class instead of starting a new ‘box’ class for each post like I would like it to do. Any help on this would be appreciated.

Here is my code I am using

    <?php get_header(); ?>

    <div id="index-float-left">

<div class="box">

<?php query_posts( 'showposts=-1' ); ?>

<?php if (have_posts()) : while (have_posts()) : the_post();  ?>

    <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> 

        <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>

        <p><?php the_content(); ?></p>

        <p class="post-date"><?php echo $post_date = get_the_date(); ?></p>

    </div>

</div> <!-- END BOX -->

    </div> <!-- FLOAT BOX BOX -->


    <?php endwhile; ?>

<?php else : ?>

    <h2>Not Found</h2>

<?php endif; ?>

<?php get_sidebar(); ?>

     <?php get_footer(); ?>

Related posts

Leave a Reply

1 comment

  1. There is a problem with “End Box” and “Fload Box Box”. Can you try like this:

    <?php get_header(); ?>
    
    <div id="index-float-left">
    
    <?php query_posts( 'showposts=-1' ); ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post();  ?>
    
    <div class="box">
        <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> 
            <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
            <p><?php the_content(); ?></p>
            <p class="post-date"><?php echo $post_date = get_the_date(); ?></p>
        </div>
    </div> <!-- END BOX -->   
    
    <?php endwhile; ?>
    <?php else : ?>
    
        <h2>Not Found</h2>
    
    <?php endif; ?>
    
    </div> <!-- FLOAT BOX BOX -->
    
    <?php get_sidebar(); ?>