-
I’ve been trying to add the time html tag for a couple of days now. I’ve noticed that GPT is pretty good with code and helping implement semantic html. However, I am struggling only with the time tag which isn’t on GeneratePress by default, but nor was a few others I have used. I want to implement it on my publish date and last updated date on my posts in my hero element section. Thanks.
-
Hi there,
Do you mean you want to change the text block’s HTML tag from
divtotime?If so, try adding this PHP code, then you should be able to see the time option in the html tag dropdown list:
add_filter('block_type_metadata', function($metadata) { if (isset($metadata['name']) && $metadata['name'] === 'generateblocks/text'){ $metadata['attributes']['tagName']['enum'] = array_merge( $metadata['attributes']['tagName']['enum'], ['time'] ); } return $metadata; }, 10, 1);Adding PHP: https://docs.generatepress.com/article/adding-php/
-
I must have gone through over 100 prompts with GPT trying to implement this lol
It’s not perfect, because it said i need datetime=”…” for machine readability but there was simply no way to add this. I tried and tried and tried! But having that time tag as an option in the dropdown is fantastic and at least the html reads as time now.
Thanks a lot Ying 🙂
-
You are welcome 🙂
- You must be logged in to reply to this topic.