Posted By

davebowker on 01/26/09


Tagged

post wordpress query latest


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
Bluewall
BrianCoyDesign


Wordpres, query for the latest post


 / Published in: PHP
 

  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
Posted By: troynt on February 3, 2009

Why not just use the query_posts() function?

http://codex.wordpress.org/TemplateTags/queryposts

You need to login to post a comment.