Hey guys got a Wordpress question. I'd be grateful for some help. Hello, I have a function i run on my single.php at the bottom of the page like so. <?php echo display_message() ?> I dont want to run the function if its on the most recent post. I've had a go myself with $getlatestpost = get_posts('numberposts=1&order=DESC&orderby=post_date'); $latestpostid = $getlatestpost ->ID; If $post->ID == $latestpostid; echo display_message(); else; /* do nothing */ endif; but its not working, can anyone help?
Hey, i've had a look there, i don't think it explains how to get the id using get_post to get the latest post. If i could compare the latest post number with the current post tha'd be fine.
It does. You can get the current post's ID with $post->ID. Once you do that, compare it with the latest post's ID with $post->ID ORDER BY post_date ASC LIMIT 1. If they don't match, it means that the current post isn't the latest one.