Style last post in loop differently?
-
I came across this post that I think answers my question but I’m not sure how to implement it into my code. Basically, I have a features box set up on the main page with 4 posts and I want to separate each one with a border-right. However, the last post in the list shouldn’t have a border at all. If you’re confused as to what I mean, you can check out https://www.gawker.com. The list of posts on top are separated by a border but the last post in that list doesn’t have one. How can I achieve the same effect?
Here is my current code which is set up in a separate loop.
<div id="carousel" style="border: 2px solid rgb(241, 241, 241); height: 184px; margin-bottom: 20px; overflow:hidden; padding:10px;"> <ul style="margin: 0pt; padding: 0pt; height:100%;"> <?php $carousel = new WP_Query(); $carousel->query('cat=3,4&showposts=4'); ?> <?php while ($carousel->have_posts()) : $carousel->the_post(); ?> <li id="carousel-post" style="border: 2px solid #f1f1f1; display:inline; float:left; height:170px; margin:0 9px; padding:5px; width:120px;"> <center><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><img class="blog-avatar" width="100" height="100" src="<?php echo get_post_meta($post->ID, "Thumbnail", true);?>" /></a></center> <h2 style="font-size:1.3em; margin:5px 0 0 0"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php if (strlen($post->post_title) > 60) { echo substr(the_title($before = '', $after = '', FALSE), 0, 60) . '...'; } else { the_title(); } ?></a></h2> </li> <?php endwhile; ?> </ul> </div>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Style last post in loop differently?’ is closed to new replies.