Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to add different style to the first post?

I think there’s a missing check for the count..? I put a counter in my frontpage.php to limit the number of recent posts which are displayed;

<?php $recent_count = 0; ?>
<?php if ( $topics || $super_stickies ) : ?>
<h4><?php _e('Recent Posts'); ?></h4>
<table id="latest">
<?php if ( $stickies ) : foreach ( $stickies as $topic ) : ?>
<?php if ($recent_count >= 10) { break; } ?>
<?php $recent_count++; ?>
<tr<?php topic_class(); ?>>
<td><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a><br /><div class="hints"><?php topic_posts(); ?> posts. <?php topic_last_poster(); ?> posted <a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a> ago.</div></td>
</tr>
<?php endforeach; endif; ?>

the $recent_count variable is incremented for each post link, and the loop is jumped out of if it hits 10. No doubt there’s a neater way of doing it, but it works fine. Checking for 1 instead of 10 would do it for you.

Skip to toolbar