Title: Display Recently Updated Posts WordPress
Last modified: August 19, 2016

---

# Display Recently Updated Posts WordPress

 *  Resolved [Fask](https://wordpress.org/support/users/fask/)
 * (@fask)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/display-recently-updated-posts-wordpress/)
 * Floating around the Internet is a piece of PHP code that is designed to display
   recently updated posts/pages in WordPress. After submitting a request to experts-
   exchange for assistance, within moments, I had the raw code I needed.
 * However, the original PHP code still didn’t work for my WordPress installation.
   After some tweaks and a lot of additional bells and whistles, I had managed to
   piece together the code needed to only display recently updated posts.
 * At this point I ask for help to show only posts from a specific category. Is 
   it possible to show only posts from a specific category? Can you help?
 * this is the current code:
 *     ```
       <div class="statistics">
       <?php
       $today = current_time('mysql', 1);
       $howMany = 10; //Number of posts you want to display
       if ($recentposts = $wpdb->get_results("SELECT ID, post_title, post_modified FROM $wpdb->posts    WHERE post_status = 'publish' AND post_type = 'post' AND post_name NOT LIKE  '%revision%' AND post_name NOT LIKE '%autosave%' AND post_modified_gmt < '$today' ORDER BY post_modified_gmt DESC LIMIT $howMany")) :
       ?>
       <h2><?php _e('ULTIME SERIE TV AGGIORNATE'); ?></h2>
       <ul>
       <?php
       foreach($recentposts as $post) {
       if ($post->post_title == '') {
       $post->post_title = sprintf(__('Post #%s'), $post->ID);
       }
       /* If no post title exists one will be assigned to it. */
       echo "<li><a href='".get_permalink($post->ID)."'>";
       echo mysql2date('d/m/Y', $post->post_modified);
       echo "&nbsp;-&nbsp;";
       echo $post->post_title;
       echo '</a></li>';
       }
       ?>
       </ul>
       <?php endif; ?>
       </div>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/display-recently-updated-posts-wordpress/#post-2012250)
 * see this thread : [http://wordpress.org/support/topic/can-i-display-most-recently-updated-entries?replies=6](http://wordpress.org/support/topic/can-i-display-most-recently-updated-entries?replies=6)
 *  Thread Starter [Fask](https://wordpress.org/support/users/fask/)
 * (@fask)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/display-recently-updated-posts-wordpress/#post-2012252)
 * I thank you for the alert but there is without solution to the problem
 *  Thread Starter [Fask](https://wordpress.org/support/users/fask/)
 * (@fask)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/display-recently-updated-posts-wordpress/#post-2012393)
 * ok I found the solution:
 *     ```
       <div class="statistics">
       <?php
       $today = current_time('mysql', 1);
       $howMany = 10; //Number of posts you want to display
       if ($recentposts = $wpdb->get_results("SELECT ID, post_title, post_modified FROM $wpdb->posts    WHERE post_status = 'publish' AND post_type = 'post' AND post_name NOT LIKE  '%revision%' AND post_name NOT LIKE '%autosave%' AND post_modified_gmt < '$today' ORDER BY post_modified_gmt DESC LIMIT $howMany")) :
       ?>
       <h2><?php _e('ULTIME REVISIONI'); ?></h2>
       <ul>
       <?php $args = array('category' => '4');
       $recent_posts = wp_get_recent_posts($args);
       foreach ($recent_posts as $post) {
       if ($post["post_title"] == ''){ $post["post_title"] = sprintf(__('Post #%s'), $post["ID"]);
       }
       ?>
       <li><a href='<?php echo get_permalink($post["ID"]) ?>'>
       <?php echo mysql2date('d/m/Y', $post["post_modified"]) ?>
       &nbsp;-&nbsp;
       <?php echo $post["post_title"] ?>
       </a></li> <?php } ?>
       </ul>
       </div>
       <?php endif; ?>
       ```
   
 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/display-recently-updated-posts-wordpress/#post-2012395)
 * excellent! 🙂
 * Please mark thread as “resolved” using the dropdown in the right panel so that:
   –
   others with similar problem can see it as “resolved” and will read this thread
   for help if they have similar problem.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Display Recently Updated Posts WordPress’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 2 participants
 * Last reply from: [t-p](https://wordpress.org/support/users/t-p/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/display-recently-updated-posts-wordpress/#post-2012395)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
