Last Updated Shortcode

Creates a shortcode to display the date/time when a post/page was last updated (with optional formatting).

Description

Creates the [lastupdated] shortcode to display the date and/or time of the last update to a post or page. If used without any arguments, it will display the date in the format configured in the Settings > General tab. It supports several optional arguments: format, before, and after. These options allow you to change how the date/time is formatted and if anything should appear before or after the date/time is displayed.

Installation

  1. Download the latest zip file and extract the last-updated-shortcode directory.
  2. Upload this directory inside your /wp-content/plugins/ directory.
  3. Activate 'Literal Shortcode' on the 'Plugins' menu in WordPress.
  4. Insert the shortcode in a post or page to return the date/time it was last modified.

Frequently Asked Questions

What is the shortcode?

You can use either [lastupdated] or [lastupdate], they both work identically.

What formatting options can I use

You can use any of the special date variables listed at this WordPress codex page. If you want to insert plain text (like the word "at" for instance) escape each letter with a backslash, \l\i\k\e \t\h\i\s.

How do I insert this in theme files?

Just wrap the shortcode in <?php do_shortcode( ); ?>. So to get the default display, just insert <?php do_shortcode( [lastupdated] ); ?>

Why did you make this?

Everyone likes a good shortcode!

Can I change the shortcode?

Yes, just open last-updated-shortcode.php and add or change what text you want to trigger the shortcode in on of the arrays near the bottom. If this gets any kind of popularity, I'll make that easier by adding an options page.

Can you add this feature I just thought of?

Can I? Yes. Will I? Yes, if I think it would be a helpful addition. I'm trying to keep things clean and simple, but there's always room for improvement, so let me know if you think a feature is lacking!

Screenshots

Last Updated Shortcode Screenshot 1
The default text that will be displayed when using the shortcode with no arguments [lastupdated].

22 Thoughts on “Last Updated Shortcode

  1. Thanks for the plugin – just what I needed!

    I was trying to get this to work in the footer and I thought I’d share the code here in case others need it too:

    The one given (below) did not work:

    • bitacre on October 4, 2012 at 11:08 pm said:

      Sorry, WP is stripping your code which it has a nasty tendency to do unless you remove a lot of the default hooks. For future reference, in the comments section of an unmodified WP site, if you just exclude the <?php and ?> tags from your PHP code, you usually won’t encounter this problem.

      Or you can just change the < and > to their respective HTML entities (which is what I just did, using &lt; and &gt; (I’ve got those two memorized, lol). I’m not sure what you’re exact solution was, but I presume it was something using the do_shortcode() function, which is a godsend. Please correct me if I’m wrong, I’m always interested to see what solutions come from other viewpoints. Thanks for the message and thanks for contributing!

    • bitacre on October 4, 2012 at 11:11 pm said:

      This also reminded me I’ve been meaning to add this exact shortcodes to the comments filter, so thanks also for that. It should work properly next time if you’re ever back in this neck of the woods :).

  2. How to translate? What is the orginal text to translate it with *.po?

    • bitacre on December 2, 2012 at 11:45 pm said:

      I have not yet internationalized this plugin, so there is no .po file. Since there is only one text string, this would be easy to do, so I will include this feature in the next update of the plugin. You can expect to be notified of an available update in the next day or so.

      When I do this, would you be so kind as to send me your translation of the .po file so I can include it natively for other users in your language?

  3. Not sure if this has anything to do with the WordPress 3.5 update, but if anyone is having trouble getting the php wrap to work, use this instead:

    <?php echo do_shortcode(‘[lastupdated]‘); ?>

    • bitacre on December 22, 2012 at 4:32 pm said:

      You don’t use echo, you just use <?php do_shortcode( '[lastupdated]' ); ?>.

      Shortcodes are designed to be returned by PHP, not echoed. Echoing a shortcode function will probably make the content jump to the very top of the page, since the code is being echoed at the time of processing rather than being returned at the appropriate location in the template. Is this what you’re experiencing?

  4. Hi there,

    I like this plugin and will use it on the site of a client. He wants to add the name of the author of the article od site. Is this possible and how do I implement this to my shortcode?

    Would be glad if you could help me.

    Thank you and greetz from germany from Irene

  5. Hi I have got the plugin working in the footer of my website but it only seem to work if a post is updated not a page I am using the genesis framework any ideas I have it in my functions file with the following:

    /** Customize the credits */ add_filter( ‘genesis_footer_creds_text’, ‘custom_footer_creds_text’ ); function custom_footer_creds_text() { echo ‘

    ‘; echo ‘Copyright © Dentistry For All · ‘; echo date(‘Y’); echo ‘ · All rights Reserved · Site By: http://www.mysite.com‘; echo do_shortcode( ‘[lastupdated]‘ ); echo ‘

    ‘; }

  6. Chanda on March 27, 2013 at 2:14 pm said:

    How would I change the color (white text)? It blends into my footer background.

  7. How can I hide the last updated time from the website. I just want to show the last updated date.

    Thanks

  8. Bwhall on April 15, 2013 at 8:35 am said:

    Love Lastmodified shortcode! I’m using the Nextgen gallery shortcode to display images on a page. Each time I add a new image to the Nextgen gallery I would like my lastmodified footer date to reflect the change without amending the actual page the Nextgen shortcode resides on. I’m hoping this makes sense and is possible?

    Kind regards

    Ben

  9. is there a way to make the text bold?

    cheers

  10. A GREAT plugin for news sites. Thank you for this great little tool :-)

  11. This is a great plugin. I use it on one of my site and doing a little modification in the time format of the plugin. I tested to update few of my post, and the date showing up the last updated date. A few days later, I checked Google, and the search result shows the last updated date too. Wow, amazing. Seems like my post was published yesterday. Many thanks for you.

  12. Hello,

    Greetings.

    I’ve a quick question regarding your “Last Updated Plugin”.

    Basically, I want it to say whatever the date was 5 days ago, at any given time. So if we look at it on the 15th, it will say it was updated on the 10th. If we look at it on the 16th, it will say 11th…

    => Last updated: “[Month Day, Year] minus 5 days” <=

    May I know is it possible to do that?

    => Also, how can I remove the time as well? (Only display the date) <=

    Appreciate if you can let me know.

    Thanks, Lee

  13. I have got a suggestion: Could you please make it HTML5 ready? That would mean the output of the shortcode would result in this: <time datetime="2009-10-22T13:59:47-04:00" pubdate="pubdate"> October 22, 2009 1:59pm EDT </time> The “pubdate” should be optional (not in default shortcode). The non-HTML5 compliant browsers would still render it normally, ignoring the unknown time tag.

    Also, there is an “undefined variable” bug in the script.

    Both things are also published here: http://wordpress.org/support/topic/a-bug-undefined-variable

    Thanks

    cry

  14. Daniel on August 4, 2013 at 10:25 am said:

    I’m hosting on GoDaddy and, despite my time settings in settings > General of “August 4, 2013″ and “3:22 pm”, the [lastupdated] shortcode displays “Last updated: August 4, 2013 at 15:21 pm”.

    Specifying a time format in the shortcode via “[lastupdated format="l, F j, Y \a\t G:i A"]” does not change the time to 12hr format like I’d expect either (and it also doesn’t show the word “at”, despite the escaping).

    Any idea why this is or know of anything specific to GoDaddy that might be causing this?

  15. Patty on August 7, 2013 at 6:28 pm said:

    The plugin works great, thank you! I would love to be able to display just the date (last updated), but not the time. Any chance that’s something easy?

  16. It would be nice if the date format could be changed to European standard, like 20-8-2013 or 2013-08-20. And like Patrik requests, hiding the updated time would be great too.

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>