0

Could anyone tell me how I can show the modified date from posts to my readers? I use Wordpress Twenty Fourteen with the Twenty Fourteen Extended plugin. Structured Data testing Tool already shows this code so I think this should be alright for rich snippets:

<meta property="article:modified_time" content="2015-08-18T17:48:22+00:00" />
<meta property="og:updated_time" content="2015-08-18T17:48:22+00:00" />

But only the publised date is shown on my site.

1

1 Answer 1

0

Look for the code that displays the post date. It should look something like the following:

Posted on: <?php the_time('l, F jS, Y') ?>

Now replace it with the following code (slightly modified from Ardamis’ post): Posted on

<?php the_time('F jS, Y') ?>
<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time != $u_time) {
echo "and last modified on ";
the_modified_time('F jS, Y');
echo ". "; } ?>
2
  • Hi Jim, thanks, but in which file can I find that code? It isn't in content.php, single.php or template-tags.php
    – Nico
    Sep 3, 2015 at 9:44
  • Hi Jim, thanks, but in which file can I find that code? It isn't in content.php, single.php or template-tags.php In template tags there is this code <pre> printf( '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>', esc_url( get_permalink() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ); <code>
    – Nico
    Sep 3, 2015 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.