[wp-hackers]Treat most recent post differently to the rest
Alex Hempton-Smith
hempsworth at googlemail.com
Thu Jan 15 00:58:17 GMT 2009
Thanks Glenn, works a treat :)
-- Alex
On Thu, Jan 15, 2009 at 12:42 AM, Glenn Ansley <glenn at glennansley.com>wrote:
> I've done this before by just testing for the loop count. $wp_query
> has this built in. The first post in the loop is 0
> global $wp_query;
> if ( $wp_query->current_post === 0 ) {
> // style for first
> }else{
> // style for the rest
> }
>
> http://codex.wordpress.org/Function_Reference/WP_Query
>
> On Wed, Jan 14, 2009 at 7:15 PM, Alex Hempton-Smith
> <hempsworth at googlemail.com> wrote:
> > Hi all,
> > On my category archives page, I'm outputting the first post into a
> different
> > HTML structure, and then outputting the rest of them below that as
> normal.
> >
> > <?php
> > $recentPosts = new WP_Query();
> > $recentPosts->query('showposts=1');
> >
> > while ($recentPosts->have_posts()) : $recentPosts->the_post();
> > ?>
> > DOING SOMETHING WEIRD TO THE MOST RECENT POST HERE
> > <?php
> > endwhile;
> >
> > while (have_posts()) : the_post(); ?>
> > OUTPUTTING THE REST NORMALLY HERE
> > <?php endwhile; ?>
> >
> > Because I've already outputted that most recent post, how do I exclude it
> > from the main output below that?
> > Almost like offset the output to start 1 post later than the most recent
> > ones.
> >
> > Hope this makes sense :)
> >
> > Many thanks,
> > -- Alex
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list