Skip to Main Content

How to display the date of an article update

Divi: the easiest WordPress theme to use

Divi: The best WordPress theme of all time!

With over 901.000 downloads, Divi is the most popular WordPress theme in the world. It is complete, easy to use and comes with more than 62 free templates. [Recommended]

Would you like to see the last update date of your articles on WordPress?

Some websites update their posts regularly and would like to present to users when the post was updated.

In this tutorial, we will show you how to easily display the date of the last update of your articles on WordPress.

But before, if you have never installed WordPress discover How to Install a WordPress Blog in 7 Steps et How to search, install and activate a WordPress theme on your blog 

Then back to why we are here.

When will you need to view the modification date of an item?

Most WordPress themes usually display the date an article was published. This is fine for most blogs and static websites.

Discover How to change the date format on WordPress

However, WordPress is also used by websites where old articles are regularly updated. This last update date is important information for these publications.

The most common example is news websites. They often update old information to add new developments, add corrections or new media files.

See also: How to display relative dates on WordPress

If only the publication date is displayed, then subscribers or visitors will miss these updates.

Many popular blogs and websites do not display any date in their articles. This is a practice not recommended and you should never delete the dates of articles in your blog.

That said, let's see how to easily display the latest update date on your WordPress articles.

How to display the date of update of an article on WordPress

In this tutorial you will be required to add code to your WordPress files. If you haven't done it before then we advise you to consult our guide how to create a WordPress plugin.

Easily create your website with Elementor

Elementor allows you to easily create any website design with a professional look. Stop paying expensive for what you can do yourself. [Free]

1 method: How to display the date before the content

You must add this code to functions.php file in your WordPress plugin:

function bpc_last_updated_date ($ content) {
$ u_time = get_the_time ('U'); 
$ u_modified_time = get_the_modified_time ('U'); 
if ($ u_modified_time> = $ u_time + 86400) { 
$ updated_date = the_modified_time ('F jS, Y');
$ updated_time = the_modified_time (); 
$ custom_content = ' Updated : '. $ updated_date. 'at'. $ updated_time. ' ';  
} 
    $ custom_content. = $ content;
    return $ custom_content;
}
add_filter ('the_content', 'bpc_last_updated_date');

This code checks if an article's publication date and modification date are different. If so, it displays the last modified date before the post content.

You can add Custom CSS to style to customize the display. Here is a small CSS that you can use as a starting point:

Go further by consulting How to remove the dates of comments on WordPress

.last-updated

 {
    font-size: small;
    Text-transform: uppercase;
    background-color: #fffdd4;

}

2 Method: How to Add the Edit Date of an Article with WordPress Theme Templates

This method requires you to edit specific files of your WordPress theme. Many WordPress themes now use their own template tags which define how these themes display metadata like date and time modified.

See also How to display the date of last connection to a user on WordPress

Some themes also use content templates or template parts to display articles.

Few simple themes will use " single.php "," archive.php , And other template files to display meta content and information. 

You will be looking for the code responsible for displaying the date and time. You can then either replace this code with the one below, or add it after the date and time of your WordPress theme code.

$ u_time = get_the_time ('U'); 
$ u_modified_time = get_the_modified_time ('U'); 
if ($ u_modified_time> = $ u_time + 86400) { 
echo " Updated "; 
the_modified_time ('F jS, Y'); 
echo "to"; 
the_modified_time (); 
echo " ";}

Discover also some premium WordPress plugins  

You can use other WordPress plugins to give a modern look and optimize the grip of your blog or website.

We offer you here some premium WordPress plugins that will help you do that.

1. WavePlayer

As you can guess from the name it bears, WavePlayer is an audio player plugin that takes the waveform of the playing audio file. With this plugin, you will be able to host tracks or simply integrate it with other cloud hosting services, such as SoundCloud.

Are you looking for the best WordPress themes and plugins?

Download the best plugins and WordPress themes on Envato and easily create your website. Already more than 49.720.000 downloads. [EXCLUSIVE]

Waveplayer premium wordpress plugins add audio player

It can also be used for podcasting purposes and it offers other features such as: HTML5 support, responsive layout, WooCommerce integration, etc. You will also be able to visually create a playlist before publishing it. Another essential feature is its speed and efficiency.

Download | Demo | Web hosting

2. Out-Of-The-Box

Out-Of-The-Box is another premium WordPress plugin that comes with a built-in Dropbox explorer. It also has an option through which you can provide your visitors with full access to your Dropbox content. It is a very good plugin for community websites.Out of the box dropbox plugin for wordpress

Notable features of the latter are among others: a complete and full system to allow your visitors to view videos and audio files stored on your Dropbox servers.

Learn as well How to duplicate an article or a page on WordPress

For example, to view the images, users will have an elegant gallery with a fully integrated lightbox that will support Lazy Loading.

Download | Demo | Web hosting

3. WP Media Folder

WP Media Folder lets you explore your media library in the same way you do with your desktop computer. It lets you drag and drop media files into folders and subfolders. Using this media manager, you will be able to manage and sort files and images. The creation of the files, the exploration and the filtering will also be done very quickly. Wp media folder

This WordPress plugin is based on the native media library. Therefore, if you uninstall it, you will not lose any files. Records are generated using a custom taxonomy. Which means that even if you move a file from one folder to another, the links will not be affected. You will be able to sort files by file type, size or title and filter them.

How to use categories and labels effectively on WordPress ? Check out this article and leave us your impressions in the dedicated section.

In addition, you will be able to import entire folders from your server to your media library. An automatic synchronization function will allow you to synchronize any folder on the server with a folder in the media library.

WP Media Folder is compatible with WooCommerce and with any other plugin that uses the WordPress media library. You can also use this plugin to add a watermark to all or some images in the media library. An extension of this plugin will facilitate integration with Google Drive, Dropbox, PDF integration and One Drive.

Download | Demo | Web hosting

Easily create your Online Store

Download free WooCommerce, the best e-commerce plugins to sell your physical and digital products on WordPress. [Recommended]

Other recommended resources

We also invite you to consult the resources below to go further in the grip and control of your website and blog.

Conclusion

Here ! That's it for this tutorial. We hope that you will be able to display the modified date of a post on your blog. If you have any questions, please don't hesitate to ask us. feel free to share the tip with your friends on your social networks.

However, you will also be able to consult our resources, if you need more elements to carry out your projects of creation of Internet sites, by consulting our guide on the WordPress blog creation.

But in the meantime, tell us about your Comments and suggestions in the dedicated section.

... 

This article features 5 comments

  1. Hello,

    Bad code ... Not functional and full of quotation marks in the code.
    Works much better this way and does not create an existing function on wordpress.
    To add on the pages at the desired location singles-content or singles or pages or other according to your configuration of themes:

    Article updated on at

Leave a comment

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

This site uses Akismet to reduce unwanted. Learn more about how your comments data is used.

Back To Top
6 shares
Share4
tweet
Save2