[Resolved] Last Updated in meta data

Home Forums Support [Resolved] Last Updated in meta data

Home Forums Support Last Updated in meta data

Viewing 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • #1310676
    Mikael

    Thanks for the explanation. That is great.

    #1310946
    David
    Staff
    Customer Support

    You’re welcome

    #1345459
    Mikael

    Hi again,

    I now finally had time to test this.

    I added the code in the functions.php.

    But when I do that, the CSS code you previously shared to make it say “Last Updated” in front of the dates on the posts does not work.

    Is there something that can be added to the code in the functions.php file to display “last updated” in front of the dates? Or a different CSS because this one seems to be overwritten by the code in the functions.php

    Thanks

    #1345486
    David
    Staff
    Customer Support

    I would use the PHP Snippet provided here:

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

    This code will only output the most recent date.

    There are two lines you can edit to add your ‘prefixes’:

    The first line is for the Published date:

    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';

    You could add ‘Published on’ for example like so:

    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on %2$s</time>';

    Now the next line is this:

    $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>';

    And to add Last updated you would change it to this:

    $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last updated %4$s</time>';

    #1345544
    Mikael

    It looks like it is working perfectly like that. Thank you very much

    #1345762
    David
    Staff
    Customer Support

    You’re welcome

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