How to Display the Last Updated Date on Your Website Using a Shortcode
To keep your content fresh and let your readers know when it was last revised, you can add a “Last Updated” date to your pages or posts. By using a simple shortcode, you can easily include this information anywhere on your website. Below is an example of how to implement this feature using a shortcode
I use fluent snippet plugin for all my functions, js, and CSS:
.time{
font-weight:bold;
color:#070537;
}
Place this coding inside code ssnippet plugin. I personally use Fluent snippet.
*This line will display Apr · 2024. you can change the
( 'M · Y' )
to match your wordpress settings in the settings → General
// Define the shortcode function
function current_date_shortcode() {
// Get the current date
$current_date = date_i18n( 'M · Y' );
// Style for the displayed date
// Return the current date with inline style
return '<span class="time">' . $current_date . '</span>';
}
// Register the shortcode
add_shortcode( 'current_date', 'current_date_shortcode' );
The short code is
[current_date]
I recomend placing this in a paragraph or a shortcode block.
Example: Last Updated: Posted: Feb · 2025 *WP Scriptly reserves the right to update any page content at any time without prior notice.
Live example is: https://wpscriptly.com/tos/ at the bottom.
Use as is
Was this information helpful?
Comments: