Wordpres, query for the latest post


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php global $wpdb;
  2. $queries = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_type='post' ORDER BY post_date DESC LIMIT 1 ");
  3. $date = $queries[0]->post_date;global $post;
  4. $post = get_post($post);
  5. $time = $post->post_date;
  6. if($date == $time) {
  7. echo "<img class='ico-new' src='";
  8. bloginfo('template_url');
  9. echo "/images/new.png' alt='' border='0' />";
  10. }?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.