Archived topic
Show modified time on the posts (If available)
7 replies · Started by Ayoosh on November 27, 2020
Hi Team,
I am trying to work on a feature, where I like to show the modified time on the post if available and fallback to the published date (if modified date not available)
I followed the instruction available on the following page
https://docs.generatepress.com/article/show-the-updated-post-date/
However on adding the given css, even the published date were not visible on my posts. Also please that I am using the "Display post date" feature under the Blog customization option in GP.
Let me know if I am missing something or doing in incorrectly?
Hi there,
Any chance you can link us to the site in question?
You can use the private information field.
Let me know :)
I have provided the required details. Please check the following URL on the frontend
https://staging.javadevjournal.com/spring-security/spring-security-session/
If you check the details, you will find that this article was updated today, however no date is visible on the front end
FYI : I am using simpelCSS plugin to add custom CSS for my site.
Hi,
To show the modified date only, use generate_post_date_show_updated_only.
https://docs.generatepress.com/article/generate_post_date_show_updated_only/
Example:
add_filter('generate_post_date_show_updated_only', '__return_true');
To add modified date AND time, you'll have to filter the date display through generate_post_date_output.
https://docs.generatepress.com/article/generate_post_date_output/
Hi Elvin,
Thanks for your response and sorry for the late response, my question was to show modified date if available else it should fall back to the publish date.
Not sure if this is possible?
Ah right,
In that case, what you'll need is a PHP snippet in this reply:
https://generatepress.com/forums/topic/showing-last-updated-and-posted-date-date-format/#post-1572165
Never-mind, I got the clue form other post and able to make it work.
Nice one. Glad you got it sorted.