Archived topic
Dynamic headline - Insert post updated date schema in the markup
5 replies · Started by George on September 7, 2021
I am using a block element in the after_header hook to display post author and updated date meta. For updated date, I use a dynamic header element with Post Date as a Dynamic text type and Updated Date as a Date type. The markup generated is the following:
<time class="entry-date updated-date" datetime="2021-07-22T08:38:52-04:00">July 22, 2021</time>
Is there a way to display the schema markup for the updated date as well?
<time class="entry-date updated-date" datetime="2021-07-22T08:38:52-04:00" itemprop="dateModified">July 22, 2021</time>
Hi there,
see Toms reply here:
And my reply here:
https://generatepress.com/forums/topic/content-template/#post-1922291
If I was to use JSON-LD instead would I need to deactivate GP schema and employ JSON-LD instead everywhere on the site?
ideally yes
Never mind, I created a shortcode:
function gm_post_date() {
ob_start();
?>
<time class="updated" datetime="<?php the_modified_time('c'); ?>" itemprop="dateModified"><?php the_modified_time('F j, Y'); ?></time>
<time class="entry-date published" datetime="<?php the_time('c'); ?>" itemprop="datePublished"><?php the_time('F j, Y'); ?></time>
<?php
return ob_get_clean();
}
add_shortcode( 'display_post_date','gm_post_date' );
and
.posted-on .updated {
display: inline-block;
}
.posted-on .updated + .entry-date {
display: none;
}
Thanks, David!
Awesome :) thanks for sharing .