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

Home Forums Support [Support request] How to show the “Last Updated” Post date when using page header edit element

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

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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

    #1146251
    Leo
    Staff
    Customer Support

    Hi 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 🙂

    #1146267
    Mayor

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

    #1146277
    Leo
    Staff
    Customer Support

    Try 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 🙂

    #1146617
    Mayor

    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

    #1147383
    David
    Staff
    Customer Support

    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

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.