Create Shortcode for WordPress Last Modified Date

Create Shortcode for WordPress Last Modified Date

If  you are looking to add the WordPress last updated, modified date to a standard post, page or custom post type then look no further…

This is a simple way to add a shortcode with a fresh date every time the post is updated, modified.

Last Modified Date – Use Cases

There are many reasons you would have a last modified on the content, but I do it for SEO and schema reasons.

I have my JSON-LD Schema markup updated every time I (or one for the team) makes a change – this is useful for Googles freshness algorithm and our site visitors knowing the info in not stale. (I will add more details on my custom Schema implementation in another post)

Note: its best to include the updated date visible on the page as well as in the Schema markup.

Last Modified Date – Implementation

There are many ways to skin a cat, here is my way – Googled with precision.

If you need to understand how to add this things to functions files, child themes etc – then Google it… I may add more at a later date – but not this time (this blog is a work in progress and mainly for my own use at this time).

I use as a plugin for many things (more on this later) – you can add this code to the >Toolset >Settings > “Custom Code” section to avoid adding to the functions file, child functions or third party code snippets plugin.  this is good for a number of reason, its removed the need to the child theme, extra functions code and has some checks in place to stop you breaking the entire site – it’s easy – always BACKUP.

// Add Short-code
function modified_date() {

   // Code
return get_the_modified_date('F j, Y');
add_shortcode( 'modified_date', 'modified_date' );

Then when adding to a page use the short code where you need it to go.
February 12, 2019

If you need to change the date format you can see the other options here in the WordPress Codex


There are many ways to do things, and this is a quick way to get the modified post date on the front end, its also useful to use in and other code you have working on the page in interesting ways – like I do in JSON-LD.

**Caveat – I am not a developer, I am someone who Google’s (ask) for solutions and tests them out.  If you are going to implement any of the information on this blog in a production or ‘mission critical’ environment – please get them checked by an experience developer – they can have consequences, and you are responsible!

Other Stuff

Eventghost Login Image Capture

Suspect someone using your logging in to your Windows 10 machine? Get the photo proof – all hidden away ready for you

Google Hire No More!

Google Hire has announced it will be closing its doors on the 1st of September 2020, in what appears to be a

Leave a comment