[Resolved] Show Published Date If Modified Date is not available

Home Forums Support [Resolved] Show Published Date If Modified Date is not available

Home Forums Support Show Published Date If Modified Date is not available

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #1125307
    Franklin

    Hi,
    I have added the CSS to show the Last Updated text and the Last modified date for the post.

    But if the post is not modified yet then it should show Published date with the same text: Last Updated

    Sample URL: https://spydrill.com/mspy-review/

    As it is not modified hence nothing shows up. I want that Last Updated text should be shown with published date in case modified time is missing.

    Thanks.

    #1125482
    David
    Staff
    Customer Support

    Hi there,

    this article provides the PHP snippet to output only the updated date if one exists, if it not it displays the published date:

    https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date

    #1127621
    Franklin

    I added the code from the link provided by you.

    It removed the link from the date but the published date is still not coming if modified date is not present.

    https://spydrill.com/mspy-review/

    #1127673
    David
    Staff
    Customer Support

    You need to remove the CSS you added to hide the published date.
    If you want to add labels e.g Published on and Last Updated then we can help edit the code in the link i provided to do that.

    #1128470
    Franklin

    On doing that, two dates are coming for the posts that have both published and modified date.

    In this case, only modified date must appear.

    Sample URL: https://spydrill.com/mspy-vs-spyzie/

    Also, we want the “Last Updated” text even when the published date is shown.

    sAMPLE url: https://spydrill.com/mspy-review/

    #1128558
    David
    Staff
    Customer Support

    If you remove any previous code (PHP or CSS) and only apply what i provided here then there should only be the single date displayed.

    #1128566
    Franklin

    Thanks, it works. Now how to get the “Last Updated” text.

    #1128582
    David
    Staff
    Customer Support

    Change this line of code:

    return sprintf( '<span class="posted-on">%s</span> ',

    to:

    return sprintf( '<span class="posted-on">Last Updated: %s</span> ',

    #1128603
    Franklin

    Thank you, David, for making it work for me!

    #1128617
    David
    Staff
    Customer Support

    You’re very welcome

    #1134679
    Franklin

    Hi David,

    The article even modified shows the published date.

    Sample URL: https://spydrill.com/cell-phone-spy-app-buying-guide/

    It is modified on 17th Jan but it shows published date 8th Jan.

    Please help!

    #1134898
    David
    Staff
    Customer Support

    Are you using JUST the code i provided here as all of your posts are still displaying both dates which they shouldn’t be. Let me know,

    #1134938
    Franklin

    Hi David,

    Please check the screenshot. I see only one date.

    #1135452
    Tom
    Lead Developer
    Lead Developer

    The other date is hidden with CSS.

    Can you share the exact function you’re using right now?

    #1135696
    Franklin

    There were repeat lines in my code. Fixed it.

    Sorry for bothering you!

    Thanks,
    Hemant

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