How to add Post’s last modified date to the Twenty Seventeen theme.
Step 1.) Add custom style for text color
/wp-content/themes/twentyseventeen/style.css
/* Change to fit your needs */
.entry-date.published {
color: #e1e1e1;
}
.modified-date {
color: #9ecbff;
margin-left: 8px;
font-style: italic;
}
/* Add a subtle separator */
.date-separator {
margin: 0 5px;
color: #666;
}
Step 2.) Modify function twentyseventeen_time_link()
/wp-content/themes/twentyseventeen/inc/template-tags.php
if ( ! function_exists( 'twentyseventeen_time_link' ) ) :
function twentyseventeen_time_link() {
$modified_time = get_the_modified_time('U');
$posted_time = get_the_time('U');
if ($modified_time > $posted_time) {
// Format for published + modified date with better spacing and structure
$time_string = sprintf(
'<time class="entry-date published">%1$s</time><span class="modified-date">Updated: %2$s</span>',
get_the_date(),
get_the_modified_date()
);
} else {
// Format for published date only
$time_string = sprintf(
'<time class="entry-date published">%1$s</time>',
get_the_date()
);
}
// Wrap the time string in a link, and preface it with 'Posted on'.
return sprintf(
'<span class="screen-reader-text">%1$s</span><a href="%2$s" rel="bookmark">%3$s</a>',
_x('Posted on', 'post date', 'twentyseventeen'),
esc_url(get_permalink()),
$time_string
);
}
endif;