Home / Archive / Display both published and modified date
Duplicate Snippet

Embed Snippet on Your Site

Display both published and modified date

‹?php
// Code from codewp.ai
function codewp_display_dates( $content ) {
if(get_post_type() != 'post') {
return $content;
}
global $post;

$published = get_the_date('F j, Y', $post);
$modified = get_the_modified_date('F j, Y', $post);
$date_string = 'Published: ' . $published . '';
if ($modified != $published) {
$date_string .= 'Last Modified: ' . $modified . '';
}
return $date_string . $content;
}
add_filter('the_content', 'codewp_display_dates');

Code Preview
php
<?php

Comments

Add a Comment