So after coming back from SES I had some interesting conversations, looked at some interesting things and came up with a few ideas. One of the things I’d like to try but have never seen is a recently updated function/plugin. How would a recently updated plugin differ from a recently published function … well I’m glad you asked …
Recently updated would be used when you are using pages or posts in a more traditional CMS environment instead of a blog one. For example say you have a library or article database of keystone or flagship content. After the site is 3-4 years old the content may be come outdated. Rather than put up a new page/post with a new URL you decide to use the existing one and update or refresh the content. It would be nice if you could have a list of the ten most recently updated articles or even a page of the 50 or 100 most recently updated pages/posts. Sure you could hack the functionality by changing the publish date but that introduces other complexities.
UPDATE
Thanks to Corey Salzano who cooked up some quick code, thanks.
< ?php
$today = current_time('mysql', 1);
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 18")):
?>
<h2>< ?php _e("Recent Posts"); ?></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; ?>
- Wordpress Plugin to Add Excerpt to Feed I’m looking for a plugin for wordpress plugin and haven’t...
- Looking for a YouTube Wordpress Plugin As both Youtube and Wordpress are mature products I would...
- Suggestion for Yahoo Shortcuts Wordpress Plugin Hey Yahoo Shortcuts Wordpress Plugin People, here’s a suggestion for...
See my disclaimer about advertising and affiliate links










{ 1 trackback }
{ 8 comments }
I am using a theme Grayland 1.0 that has this functionality built into the bottom of the template by default. The developer’s site is dandyland dot org. I wonder if all this PHP will paste nicely?
get_results(“SELECT ID, post_title FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_date_gmt
post_title == ”)
$post->post_title = sprintf(__(‘Post #%s’), $post->ID);
echo “ID).”‘>”;
the_title();
echo ‘‘;
}
?>
Nope!
It seems like it would be easy to hack your way to this sort of functionality in a theme. Using the wpdb class would make it easily to access any sort of info that you might need. The “posts_modified_gmt” field in the posts table would be the one you’d want to go after, not the “post_date_gmt” field being used above. I would use the query below:
SELECT *
FROM $wpdb->posts
WHERE `post_status` = “publish” AND `post_type` = “page”
ORDER BY `post_modified_gmt` DESC
Then you’d just need to print out like ten rows worth somewhere on your page or whatever.
On the other hand, doing it in a plugin is a little more complicated, although not overly difficult.
Thanks Michael and Corey for getting this in place. This plugin is a perfect fit for an instructional site I’m making with WordPress.
tx’s for the information that’s plug in to help full improve my WP
Michael
Under the Publish Status section there is the option to change the post to a different date than it was originally created. Would this not do the same thing as the code above?
David
@David Wilson: yes but the goal is to not throw the page back into the RSS of new posts
Well, the RSS thing is one aspect, but there’s also the manual work aspect of that solution. Not to mention that there’s no point because WP automatically keeps a field for the latest update already.
Comments on this entry are closed.