Site logo

Archived topic

How to show the “Last Updated” Post date when using page header edit element

5 replies · Started by Mayor on January 27, 2020

Viewing posts 1–6 of 6

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

Yes, this is the code I placed in the header element.

` <h1>{{post_title}}</h1>
Written by {{post_author}} on {{post_date}}

https://prnt.sc/qtr9na

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' );

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

Hi 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

This archived topic is closed to new replies.