Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Can I display a condition for displaying published date vs modified date?

  • #10582
    Avatar photo[anonymous]

    I’m trying to display the last published date of post is more recent than the published date of the post but I’m not sure how to do this. I attempted to do it with {{compare}} but that didn’t work.

    So what I’ve resorted to is the following which doesn’t seem to work very well. If anyone has any advice on how I can display the updated date for a post if it’s more recent than the published date that would be amazing!

    {{#checkIfAny @config.post.displayLastUpdatedDate @config.post.displayDate}}
                            {{#if @config.post.displayLastUpdatedDate}}
                               {{#if modifiedAt}}
                                  <time datetime="{{date createdAt 'YYYY-MM-DDTHH:mm'}}">
                                     {{#checkIf @config.custom.formatDate '!=' 'custom'}}
                                        Last Updated: {{date modifiedAt @config.custom.formatDate}}
                                     {{else}}
                                        Last Updated: {{date modifiedAt @config.custom.formatDateCustom}}
                                     {{/checkIf}}
                                  </time>
                               {{/if}}
                            {{/if}}
                            {{else}}
                                  <time datetime="{{date createdAt 'YYYY-MM-DDTHH:mm'}}">
                                     {{#checkIf @config.custom.formatDate '!=' 'custom'}}
                                        Published: {{date createdAt @config.custom.formatDate}}
                                     {{else}}
                                        Published: {{date createdAt @config.custom.formatDateCustom}}
                                     {{/checkIf}}
                                  </time>
                         {{/checkIfAny}}
    #10586
    Avatar photoBob

    You don’t need a condition, just provide a modified date which will return the publish date if the post hasn’t been modified.

    #10592
    Avatar photo[anonymous]

    Thanks Bob understood, however what if I wanted to display text alongside the date to show the text “Published:” along with the published date if the page has not been modified since the date of being published and the text “Updated:” along with the updated date if the page has been modified since the date of being published. Is this possible to do?