Support » Themes and Templates » Separate boxes for excerpts?

  • Resolved philfresco

    (@philfresco)


    I’m sure this question would have been posted somewhere before, but I can’t quite name what I’m trying to do in a way that would be suitable for searching the forums…apologies if this is a repeat question. I imagine this is simple to answer anyway:

    I have a very simple theme at the moment, and on my homepage I have a container listing all the excerpts of the most recent posts in chronological order, as most websites do. However, instead of having all the posts in one container, I would like for each post to be broken up into separate boxes.

    Here is an example of what I mean – http://wordpress.org/extend/themes/ahimsa – on the Ahimsa theme, each post on the homepage is in it’s own section/box. How do I do that?

    Thanks, Phil.

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi

    (@esmi)

    Forum Moderator

    Site url?

    philfresco

    (@philfresco)

    Sorry, but I’ve not got the site up at the moment. I know you could really do with seeing what you have to work with, which I why I know you may not be able to answer the question. If you could guess and give me anything to try, it would be greatly appreciated.

    Thanks, Phil.

    esmi

    (@esmi)

    Forum Moderator

    Try using something like:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div <?php post_class('postbox');?>>
    [...]
    </div>
    <?php endwhile; ?>

    That should provide you with a class called “postbox” that you can then style via CSS.

    philfresco

    (@philfresco)

    Looking at my code, I actually do have basically the same code that you gave me above. I am able to style the “postbox” via CSS, but I can’t seem to style it so that there’s a gap in-between the individual posts. I just need to have a 10px gap in-between each post, where the background of the page shows through. At the moment, I have one central div box with the loop in it, so all of the posts are displayed in one styled box in a list. However, I would like each post to be separated up into their own boxes, kind of like a divider; so the desired effect is that there’s a box with a border on it with the first post, then a 10px gap, then another box with a border on it with the second post in it, then another 10px gap, then so on. I tried adding a 10px margin to the “postbox”, however it only made a white space in-between the posts, and didn’t spilt the box up (as I thought it would do). I just can’t seem to think of a way to do it!

    Any more ideas? Thanks, Phil.

    Check whether this is what you are looking for

    Adding separate boxes for posts

    philfresco

    (@philfresco)

    Thanks for the link GJames, it did the trick! This is exactly what I was trying to search for, but it just didn’t show up in search engines!

    And also thank you esmi for helping.

    Thanks, Phil.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Separate boxes for excerpts?’ is closed to new replies.