I run a news website, and I think there are considerable benefits to adding a last date updated option to it. However, everything I see online is for replacing the published date with the date modified. I want both, like in this article by the NYT.
What's more, I don't want this on every article since I edit articles a lot and don't always want each of them to reflect it. Instead, I want it for "evergreen" content that has proven popular long after it was published; my hope is that Google shows the more recent time in search results. As a result, I prefer doing this with a custom field or a CF plugin -- I currently have CMB2 installed.
The not-very-helpful theme I use uses the below function to add dates to posts:
if (!function_exists('mh_magazine_post_meta')) {
function mh_magazine_post_meta() {
$mh_magazine_options = mh_magazine_theme_options();
if ($mh_magazine_options['post_meta_date'] === 'enable' || $mh_magazine_options['post_meta_author'] === 'enable' && in_the_loop() || $mh_magazine_options['post_meta_cat'] === 'enable' && in_the_loop() && is_singular() || $mh_magazine_options['post_meta_comments'] === 'enable') {
echo '<div class="mh-meta entry-meta">' . "\n";
if ($mh_magazine_options['post_meta_date'] === 'enable') {
echo '<span class="entry-meta-date updated"><i class="fa fa-clock-o"></i><a href="' . esc_url(get_month_link(get_the_time('Y'), get_the_time('m'))) . '">' . get_the_date() . '</a></span>' . "\n";
}
if ($mh_magazine_options['post_meta_author'] === 'enable' && in_the_loop()) {
echo '<span class="entry-meta-author author vcard"><i class="fa fa-user"></i><a class="fn" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>' . "\n";
}
if ($mh_magazine_options['post_meta_cat'] === 'enable' && in_the_loop() && is_singular()) {
echo '<span class="entry-meta-categories"><i class="fa fa-folder-open-o"></i>' . get_the_category_list(', ', '') . '</span>' . "\n";
}
if ($mh_magazine_options['post_meta_comments'] === 'enable') {
echo '<span class="entry-meta-comments"><i class="fa fa-comment-o"></i>';
mh_magazine_comment_count();
echo '</span>' . "\n";
}
echo '</div>' . "\n";
}
}
}
add_action('mh_post_header', 'mh_magazine_post_meta');
How do I do this? I don't like installing plugins, so I am thinking of something I can add myself and call through a custom field.