scriptygoddess RSS Feed
 
 
 
 

Show recently edited/updated posts

I've been going back in and modifying some existing posts - and I thought it would be useful to see a list of posts that were recently edited.

This function would go in your my-hacks.php file. I created it quickly for my own uses - wanted to keep it here for "code storage" - but you will probably want to customize the code so that it does what you want it to.

function displayRecentlyUpdatedPosts () {
global $wpdb, $tableposts;
$now = current_time('mysql');
$arcresults = $wpdb->get_results("SELECT ID, post_date, post_title, post_modified FROM $tableposts WHERE post_modified < '$now' AND post_status = 'publish' AND post_modified != post_date ORDER BY post_modified DESC LIMIT 20");
if ($arcresults) {
foreach ($arcresults as $arcresult) {
if ($arcresult->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult->ID);
$arc_title = stripslashes($arcresult->post_title);
if ($arc_title) {
$text = strip_tags($arc_title);
} else {
$text = $arcresult->ID;
}
$post_date = substr($arcresult->post_modified, 0, 10);
$post_day = substr($arcresult->post_modified, 8, 2);
$post_year = substr($arcresult->post_modified, 0, 4);
$post_month = substr($arcresult->post_modified, 5, 2);
$post_hour = substr($arcresult->post_modified, 11, 2);
$post_min = substr($arcresult->post_modified, 14, 2);
$post_sec = substr($arcresult->post_modified, 17, 2);
$amPm = "am";
if ($post_hour > 12) {
$post_hour = $post_hour - 12;
$amPm = "pm";
}
echo "<p>".$post_month.".".$post_day.".".$post_year." ".$post_hour.":".$post_min." ".$amPm."<br /><a href="".$url."">".$text."</a></p>";
}
}
}
}

4 Responses to “Show recently edited/updated posts”

  1. 1
    will:

    Maybe you should purchase the domain http://www.wordpressgoddess.com :P

  2. 2
    Daynah:

    lol Will!

    Jennifer, instead of using my-hacks.php you should go ahead and make it a plugin. The my-hacks.php was the old way of hacking at wp. :D

    Great hack/plugin by the way. :D

  3. 3
    WxGal's World :: Journal » Update to Trackback Popup plugin:
    [...] this plugin, please make sure to get the updated code. Maybe I should install Scripty's Show Recently Edited posts plugin since I've [...]

  4. 4
    Mama Write:
    Various WordPress Links
    Rather than ping ScriptyGoddess multiple times and clog my sideblog with even more WordPress links, I decided to plop 'em all here. I'm going to give WordPress a try again on my course website, since there are various hacks that…

Bookmarks

WordPress Resources

Meta

Random Stuff