• I am using this code, below, to display only one category of posts on a particular page. Works great for my purpose (I don’t need titles or metadata).

    The only thing is I am not able to style the individual posts. All of the posts seem to react as a unit or block. Specifically I would like to put a margin between the individual posts. That would require a <div> I think, but where to put it?

    Any help?

    <?php
    query_posts('cat=16');
    while (have_posts()) : the_post();
    the_content();
    endwhile;
    ?>

    Thanks

    Wolfy

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can try something along these lines …

    First a small change to your code:

    <?php
    query_posts('cat=16');
    while (have_posts()) : the_post();
    <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    the_content();
    </div> <!-- .post #post-ID -->
    endwhile;
    ?>

    By adding the “post_class()” function to your code you open up a set of CSS classes that may allow you to style your output more to your preference. For example your code will now provide you with the class: ‘category-category-16’ which can possibly be used with the ‘post’ class element, for example:

    .post .category-category-16 {
      margin: 9px 0;
    }

    Hope that helps some …

    Thread Starter mrwolfy

    (@mrwolfy)

    Thank You!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with styling the loop’ is closed to new replies.