[Resolved] Show modified time on the posts (If available)

Home Forums Support [Resolved] Show modified time on the posts (If available)

Home Forums Support Show modified time on the posts (If available)

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1552826
    Ayoosh

    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?

    #1553102
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the site in question?

    You can use the private information field.

    Let me know 🙂

    #1556795
    Ayoosh

    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.

    #1557156
    Elvin
    Staff
    Customer Support

    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/

    A wise man once said:
    "Have you cleared your cache?"

    #1596113
    Ayoosh

    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?

    #1596121
    Elvin
    Staff
    Customer Support

    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

    A wise man once said:
    "Have you cleared your cache?"

    #1596122
    Ayoosh

    Never-mind, I got the clue form other post and able to make it work.

    #1596123
    Elvin
    Staff
    Customer Support

    Nice one. Glad you got it sorted.

    A wise man once said:
    "Have you cleared your cache?"

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