WP plugin: Post Updated
- plugin:
- Post Updated
- version:
- R1
- download:
- post-updated.zip
- source:
- post-updated.php
Time for a new WordPress plugin! Post Updated is a simple fellow: it displays the last modified date and time for a post (that is, if later than the original post date). Useful for providing a “last updated” flag to your posts.
To install and use Post Updated, download the zip file, extract post-updated.php, upload this to your wp-content/plugins/ directory, and activate the plugin in WordPress. The function post_updated() must be used in The Loop.
Usage:
<?php post_updated('format', hours, 'before', 'after', gmt, display); ?>
Parameters:
- format
- (string) Format modified date/time is to display in. Defaults to date and time formats configured in your WordPress options. For help in modifying, see the PHP manual on date and time format parameter strings.
- hours
- (integer) Number of hours allowed between original post timestamp and modified timestamp before displaying modified date/time. Defaults to
3. - before
- (string) Text to display before modified date/time. Defaults to
'Last updated: ' - after
- (string) Text to display after modified date/time. There is no default.
- gmt
- (boolean) Use Greenwich Mean Time timestamp for posts (
TRUE), or use the standard timestamp (FALSE). Defaults toFALSE. - display
- (boolean) Display modified time/date (
TRUE), or return modified timestamp to be used in PHP (FALSE). Defaults toTRUE.
Examples:
<?php post_updated('', 6, '<span class="meta">Last modified: ', '</span>'); ?>
Displays modified date/time in default format if modified time is more than 6 hours after original post time; placed in a span tag using the css class ‘meta’ and prefixed with the text “Last modified: ”.
<?php post_updated('M j, Y', 24, '<p>Updated: ', '</p>'); ?>
Displays modified date for post if modified time is more than 24 hours after original post time. Display format is “Updated: Feb 23, 2005″ (in a paragraph tag).
Author: Kaf Oseo
Categories: WordPress
Comments: (49) · Leave a comment · Comments RSS2
This is great but I’m curious how it compares with this last-modified plugin? I use this and it works for me. What’s I’d really like is to modify WordPress to recognize “last-modified” as the sort order rather that the post date, since I don’t run a traditional blog.
Thanks.
It varies from Nick’s plugin (which I hadn’t known about before, thanks) in that you can specify not just the format for the date/time, but also:
* A “grace” period from the original post timestamp. If you tend to make grammatical changes after posting an article but don’t want this to set off the plugin, you can tell it to allow for some amount of time (by hours).
* Before and after text.
* Use regular or GMT time.
* Either display the modified timestamp or return for coding use.
What you’re looking for is way over the head of my little plugin here. But I’ll dig through the WordPress core to see what it would take.
With Nick’s plugin, you can modify the date and time – it works on PHP time/date funcitions. But I like what’ you’ve done with this. I might just have to replace his with yours…hee hee.
Thanks for the great work and the lovely site.
Thanks for the kind words, fellow WP traveller. Like Nick’s plugin, Post Updated also acccepts PHP date format strings, defaulting to WordPress settings if you choose not to play with them.
In regards to Nick, I’ve a lot of respect for him and his work. Why else would I have stolen some of his code for my first plugin? Sure there’s a lot of possible reasons, but trust me, it was the respect.
Probably a greta plugin but can’t get it to work :-/ Uploaded the plugin file, activiated it and added Updated: ‘, ”); ? > within the loop. Got no errors … just that nothing happens even if I update a post.
Something I’ve missed? Any suggestions?
Thanks :-)
Sean,
Checking your site, from the “Updated” elements showing on some posts it looks like you worked out the kinks in setting up the plugin. Good stuff.
Do you know of anyway to modify the ‘last updated’ date? I moved a bunch of posts over and had to fix the categories. Now they ally show as having been updated recently. I would really like to restore them back to their original date.
Gary, I sent you an email.
Re: Lorelle
You can change the sort order to use the post_modified field. Check this old wiki page for instructions. Note: the $allowed_keys array is now inside “/wp-includes/classes.php” (WP 1.5).
I’ve been looking for some way to display the modified times of pages instead of the created time. This did the trick. Thank you!
Does this plugin work for pages as well as blog entries?
Yes.
Hello, I really need help. I am on WP2.0. Downloaded the package, activated it in the control panel. Then? I don’t understand “the loop” thing. Any more detail instructions? Thanks.
Info on The Loop:
http://codex.wordpress.org/The_Loop
If you know anything about WordPress Template Tags and how to use them in your templates, then you’ll know how to put this (and other such template taggish) plugin into operation.
works great.
thanks.
Hey there,
I’m trying to work out a way where I can use such a script, but for it to only appear on the main site (the blog default page), but put a universal ‘this site was modified’ rather than a ‘this post was modified’. Is this possible?
Say I updated the main page’s latest post on 3rd March, but I updated another separate page on the blog on the 4th March. How do I get the main page to ignore the ‘post updated’ and print only the latest overall update on *any* page?
I added the script to the page.php, it displays the update for each individual page, but I would like to just have one on the main that takes the date/timestamp from whatever page was last updated. Is that easy to do, can I edit the existing script or do I need a totally different sort?
Hope that makes sense.
aketus, it makes perfect sense. But my plugin would not work here, and I don’t know of one offhand that does what you’re looking for.
However, there’s not much involved in getting this info and displaying it, so I’ll email you a bit of code which accomplishes what you’re after.
Just what I was looking for. Definitely saved me from coding. Thanks, it works great for me.
I see where you said this will work for Pages, too. I’m using a theme called Simpla which doesn’t have a page.php. Could that be the problem?
Does this also work when a post is commented on? I’d like to have a way to have a post date/time updated when someone makes a comment to a post.
Thanks!
This plugin worked locally for me (php5) however when I tried it only (php4) nothing is displayed. Do you know if php4 is supported?
I would like my posts to show me the real time and my pages to show me the time it is updated. How do I do that in the template. I don’t want both times to be shown. Is it possible?
Is there an easy way to get the same functionality working outside The Loop? I’d like to include the modified date in the footer.
Thanks!
I’m looking for a plugin that lists the last 5 updated entries, just like the recently posted entries list. Is it possible to create such a list with this plugin, or could you create something like that?
Works well in my site and blog. I run it on PHP 5 so no problems. Thanks!
Hi there! This plugin is sort of what I’m looking for but not quite, I was wondering if you knew of anything that could help. Basically, I want to have a link list of pages on my home page and when they were last updated, like this:
Page 1 – 08/01/07
Page 2 – 23/12/06
Page 3 – 13/11/06
Then say Page 3 gets updated, its link would pop up to the top of the list.
I realise this is probably pretty specific functionality, so I understand if you’re unable to help in this regard, I was just wondering if your plugin could possibly be modified to do it. Thanks!
Sweet! It does work on the index! Thank you for the code! :o)
Hmm. No it doesn’t. At least, not without rewinding the loop in the footer. Oh well, it works on pages and posts. Thanks again!
I can confirm that this plugin still works in 2.1.2 :)
Thanks for a great plugin! I’m new to WP and blogging in general, so I had to play around with it for a while to get it exactly how I wanted. But I definitely got my pages to display the updated dates. Thanks again!
hi, i run a multiple author blog and i want to display the name of the author who last modified the post. tis can be placed at the end of the article and i want the original author name below the heading to be intact. any trick?
Thanks for the plugin work. It works great on my site. It’s the first time I’ve really had a bit of a twiddle with editing a php file and sticking comments in. It’s kicked off my brain in that area so thanks again.
Rees
Plugin post_updated() doesn’t work for my new pages:
The “last_updated” works for existing pages since I have added the plugin post_updated(). But the “last_updated” does not show up for the new pages that are created after plugin being added.
This is what I have in the index.php:
by
Does anyone know why and how to fix it? Thanks.
Oh, I think that I have to use both “posted” as well as “post_updated” to handle the new and existing pages. I thought that post_updated() would handle both scenarios.
Please do share your comments if you know a way that post_updated can handle new and existing pages. thanks.
I’m looking for the same thing, an overall “Site Last Updated” display, can you send this code to me also?
Thanks!!!
jon
“Hey there,
I’m trying to work out a way where I can use such a script, but for it to only appear on the main site (the blog default page), but put a universal ‘this site was modified’ rather than a ‘this post was modified’. Is this possible?
Say I updated the main page’s latest post on 3rd March, but I updated another separate page on the blog on the 4th March. How do I get the main page to ignore the ‘post updated’ and print only the latest overall update on *any* page?
I added the script to the page.php, it displays the update for each individual page, but I would like to just have one on the main that takes the date/timestamp from whatever page was last updated. Is that easy to do, can I edit the existing script or do I need a totally different sort?
Hope that makes sense.
Kaf
Comment » March 8, 2006 @ 12:24 am
aketus, it makes perfect sense. But my plugin would not work here, and I don’t know of one offhand that does what you’re looking for.
However, there’s not much involved in getting this info and displaying it, so I’ll email you a bit of code which accomplishes what you’re after.”
Still going strong in 2.7. One of those plugins that really does what it says on the tin but is so understated.
Hi. Nice plugin! Really does the job, and working fine in 2.8! One feature I’d like is to add who made the most recent change. I have multiple editors and I’d like something like the_author() but the one that made the most recent edit…
Still works in WordPress 3.0.3, too. Great plugin!