Home › Forums › Support › How to show the “Last Updated” Post date when using page header edit element
- This topic has 5 replies, 3 voices, and was last updated 6 years, 3 months ago by
David.
-
AuthorPosts
-
January 27, 2020 at 1:21 pm #1146156
Mayor
Please, i need help on how to show the last updated post date, and also on reducing the font size for the Author Name and Date?
Thanks
January 27, 2020 at 3:37 pm #1146251Leo
StaffCustomer SupportHi there,
– This should help:
https://docs.generatepress.com/article/show-the-updated-post-date/#show-the-%E2%80%9Cupdated%E2%80%9D-post-date-in-header-element– Are you going to add the author name and date in the header element?
Let me know 🙂
January 27, 2020 at 4:17 pm #1146267Mayor
Yes, this is the code I placed in the header element.
` <h1>{{post_title}}</h1>
Written by {{post_author}} on {{post_date}}But i don’t know how to add this code to the above, Please, how can i do it?
function post_modified_date() {
return get_the_modified_date();
}
add_shortcode( ‘modified_date’, ‘post_modified_date’ );January 27, 2020 at 4:58 pm #1146277Leo
StaffCustomer SupportTry this for your HTML:
<h1>{{post_title}}</h1> <div class="hero-meta">Written by {{post_author}} on {{post_date}}</div>Then add this CSS:
.hero-meta { font-size: 10px; }Adding CSS: https://docs.generatepress.com/article/adding-css/
The code to create shortcode needs to be added with one of these methods:
https://docs.generatepress.com/article/adding-php/Let me know 🙂
January 28, 2020 at 2:36 am #1146617Mayor
The code you provided works perfectly. But it is not showing the date a post is updated. Something like, when I update a particular post, it should show that the post was updated
January 28, 2020 at 10:40 am #1147383David
StaffCustomer SupportHi there,
Did you add the add_shortcode function to your site?
If so remove it and add this instead:function display_modified_date_shortcode () { $mod_date = get_the_modified_date(); if ( get_the_date() !== $mod_date ) { return 'Last Updated: ' . $mod_date; } } add_shortcode( 'modified_date', 'display_modified_date_shortcode' );https://docs.generatepress.com/article/adding-php/
Then add
[modified_date]to your Header Element.
If the Post has been updated ( there has to be a days difference between published and modified ) it will also display the Last updated date -
AuthorPosts
- You must be logged in to reply to this topic.