• Hi there,

    I’ve been using the free version of Generatepress for a while now and love it. I’ve managed to do quite a lot of customising and fiddling with the CSS to get it almost perfect for me.

    However I’ve encountered a problem I can’t seem to sort. I’ve seen it crop up as a question in various forms quite a bit though so I’m hoping there’s an easy solution.

    I currently only show the “Last Updated” date on posts, and if there’s only the published date or it hasn’t been updated then no date is shown. I noticed that I’d done this with CSS to hide the published date but it was still present in the HTML along with the Schema.

    So, is there a quick and easy function to remove that published date and Schema from the HTML? I only want the last updated/dateModified, nothing else.

    That’s the main issue and I’ll be more than happy just to solve that. However if there were someone really clever they might be able to help me take it a step further:

    If there was only the published date (I.e no update or modification had been done), could I show that but have it set as the modified date. So something like <time itemprop=”dateModified” datetime=”published date here”> but then if the post has been updated that updated date is used instead? I hope I’ve explained that clearly!

    And lastly (sorry for all the questions) am I right in thinking the Premium version makes all I’m asking for super simple? Just a tick box option in the customising settings? If so then I’m considering switching which leads to my (I promise!) final question – is upgrading from the free to Premium straightforward? Would it likely mess up the changes and tweaks I’ve made to the free version?

    Thanks and apologies for the length of this!

    – Andy

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there,

    use this PHP Snippet here:

    https://docs.generatepress.com/article/generate_post_date_show_updated_only/

    It will only output the Updated Date HTML if its present, if not it will display the published date. Then there should be no need for your CSS to hide things.

    Regarding GP Premium – its a plugin that extends the functionality of the free theme. Enabling it will not make any changes to your site, just a wealth of new features to enable.

    In this case you would still need the above snippet, unless you build your meta using the GPP 2.0 dynamic Block Element

    Thread Starter Andyml

    (@andyml)

    Hi David,

    Thanks for getting back to me.

    I have actually tried that snippet and found it didn’t work. In fact I’ve still got it in my functions and here’s the HTML from one of my posts:

    <span class=”posted-on”><time class=”entry-date published” datetime=”2021-02-27T16:09:40+00:00″ itemprop=”datePublished”>February 27, 2021</time><time class=”updated” datetime=”2021-03-08T15:41:55+00:00″ itemprop=”dateModified”>March 8, 2021</time></span>

    So it doesn’t seem to be having the desired effect. And that’s really why I ended up posting this, as none of the other solutions I came across from my own searching worked for me.

    Any ideas why? Or other options to try?

    Thanks for the help, really appreciate it.

    – Andy

    Do you have any other related functions ?

    Thread Starter Andyml

    (@andyml)

    D’oh! I had an old function where I’d tried to achieve the same thing and had got close but not quite there. It was still hanging around. Removed it and hey presto! It seems to be working now.

    I feel like a right idiot now!

    Apologies for wasting your time and thanks so much for the help.

    No apologies necessary – glad to hear you got it working!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Published Date HTML and Schema’ is closed to new replies.