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 " - "; echo $post->post_title; echo '</a></li>'; } ?> </ul> <?php endif; ?> </div>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Display Recently Updated Posts WordPress’ is closed to new replies.