Title: Recently modified posts
Last modified: August 19, 2016

---

# Recently modified posts

 *  Resolved [deckster0](https://wordpress.org/support/users/deckster0/)
 * (@deckster0)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/recently-modified-posts/)
 * I found this om wp-recipes, could someone modify this code so that it only lists
   a new post if pressed “update post” and not publish.”
 *     ```
       <?php
       $today = current_time('mysql', 1);
       $howMany = 5; //Number of posts you want to display
       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")):
       ?>
   
       <h2><?php _e("Recent Updates"); ?></h2>
       <ul>
       <?php
       	foreach ($recentposts as $post) {
       		if ($post->post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);
       		echo "<li><a href='".get_permalink($post->ID)."'>";
       		the_title();
       		echo '</a></li>';
       	}
       ?>
       </ul>
       <?php endif; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/recently-modified-posts/#post-1296234)
 * This will return posts where the post date and the post modified date do NOT 
   match
 * Change:
 *     ```
       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")):
       ```
   
 * to:
 *     ```
       if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_modified_gmt != post_date_gmt ORDER BY post_modified_gmt DESC LIMIT $howMany")):
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Recently modified posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/recently-modified-posts/#post-1296234)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
