Posted By

selfmadepsyche on 02/17/09


Tagged

wordpress


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

rezzz


Display Recently Updated Posts/Pages


 / Published in: PHP
 

  1. <?php
  2. $today = current_time('mysql', 1);
  3. $howMany = 5; //Number of posts you want to display
  4. if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_modified_gmt < '$today' ORDER BY post_modified_gmt DESC LIMIT $howMany")):
  5. ?>
  6. <h2><?php _e("Recent Updates"); ?></h2>
  7. <ul>
  8. <?php
  9. foreach ($recentposts as $post) {
  10. if ($post->post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);
  11. echo "<li><a href='".get_permalink($post->ID)."'>";
  12. the_title();
  13. echo '</a></li>';
  14. }
  15. ?>
  16. </ul>
  17. <?php endif; ?>

Report this snippet  

You need to login to post a comment.