A modified date will let web visitors know the date that an article was updated, not the publish date (which probably was several years ago!). It provides some trust to the content of the article, also is a plus point for SEO.
I use Newspaper theme in two WordPress websites. It works amazingly as described, only that I could not display the modified date instead of the published date, from the Theme Panel.
I tried the Show Modified Date in the Theme Panel, but it does not work as it should be. Then, I made a child theme and override the time values as this instruction. Still not work.
Finally I can display the modified date to the front end with WordPress hooks. In my opinion, this is quite a clean way to complete the task.
In this post, I will show how to do it. Also, you can apply this method not just in Newspaper theme but also in any other themes, because the principle is the same:
- First, do a bit of investigation to the theme: How they display the publish date in post settings
- Second, remove that information from the theme settings, or just set display: none; if theme options do not provide that
- Third, hook onto the_title, or the_content, and add modified date before / after title or content
Let me show in more details the third point.
Display modified date by hooking to article’s title or content
WordPress provides users a convenient way to intervene in its basic flow, by using actions and filters (or hooks). That is to say, if you would like to add some information before the article content show, just use the_content. Similarly, you can use the_title to make changes related to the entry title.
So, if you can access your theme child’s functions.php, process as below.
If you cannot access the theme’s functions, install Code Snippets plugin and proceed the code below as a new snippet, and select Only run on site front-end.
Get the modified time
To show the modified date, use get_the_modified_time().
For Newspaper theme, use the td-module-meta-info and td-post-date classes to get classes styled as the demo.
For other themes, use whatever class you want, maybe inherit from the theme, or you can create one and style it later.
Hook it to the_title or the_content
If you would like to display it before the content:
If you would like to display it after the title:
Personally, I prefer to attach it before the content, because if it is attached after the title, it will go inside the h1 tag.