I don’t remember anything like that. And I don’t even think is needed – if you have your Loop to show 1 (one) post, that’s always the latest (unless you tell it to do otherwise :).
Thread Starter
syni
(@syni)
Yeah, but I want certain images to change depending on if the post is the latest or not. So, I’m confused. :p
You could probably do something like the following inside the Loop.
if ($wp_query->current_post == 0 && is_home()) // latest post
{
}
EDIT: make sure to use that code only in the front page
EDIT2: ok. I edited the code above. should be more bulletproof now.
Thread Starter
syni
(@syni)
Thanks Alphaoide. Is there a way to do this on a single post page too?
The following solution makes my previous solution obsolete.
What you want to do is
(Before the Loop begins)
1. Get one latest post with template tag get_posts
2. Get the date of that latest post.
(Inside the Loop)
3. Compare the current post’s date with latest post’s date
So, step 1 and 2 would be…
<?php
$latest_post = get_posts('numberposts=1');
$latest_date = $latest_post[0]->post_date;
?>
and step 3…
<?php
if ($latest_date == $post->post_date) :
echo "LATEST";
endif;
?>
Thread Starter
syni
(@syni)
Thank you! That works perfectly!