Code Snippet
Display Post Divider In Between Posts
Right before the closing of the The Loop, insert this code:
<?php
if (($wp_query->current_post + 1) < ($wp_query->post_count)) {
echo '<div class="post-item-divider">Post Divider</div>';
}
?>This will create a <div> you can style as a post divider. The cool part being, it only gets inserted between two posts, skipping the last one. Thanks to Craig Maclean.
This piece of code is excellent and saved my day, thanks!
What’s great is you can utilize this technique to output just about anything you want before and after your post data, including objects with specific id’s for manipulation with javascript.
Gotta love the loop.
Wow, this code is awesome! I’ve been looking for ways to separate posts easily for a while, this is definitely something I’ll set up!
Could you use this to insert adverts or adsense – how?
many thanks
What if you have excluded posts. Then the divider will show up even when it’s blank. Help?