scriptygoddess

22 Jun, 2004

Show recently edited/updated posts

Posted by: Jennifer In: WordPress my-hacks additions

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 | WxGal's World :: Journal » Update to Trackback Popup plugin

June 25th, 2004 at 4:51 pm

Avatar

[…] this plugin, please make sure to get the updated code. Maybe I should install Scripty's Show Recently Edited posts plugin since I've […]

2 | will

June 23rd, 2004 at 12:51 pm

Avatar

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

3 | Daynah

June 23rd, 2004 at 2:44 pm

Avatar

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. 😀

Great hack/plugin by the way. 😀

4 | Mama Write

July 7th, 2004 at 8:01 pm

Avatar

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…

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements