Site logo

Archived topic

Last Updated in meta data

20 replies · Started by vanya on May 28, 2020

Viewing posts 16–21 of 21

Thanks for the explanation. That is great.

You're welcome

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

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>';

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

You're welcome

This archived topic is closed to new replies.