Add Last Modified Date to Your Single Blog Post Meta

This is a Developer Level doc.

If you're unfamiliar with PHP and/or editing files, codes and templates, as well as with resolving possible conflict, please seek help from a professional. Under our Support Policy, we don't provide support for modifications and customization.

This feature is already a part of the OceanWP theme.

Navigate to Appearance > Customize > Blog > Single Post, and click the eye icon of the Modified Date meta element to display it.

To include the Last Modified Date into your single blog post meta, use the following PHP snippet:

// Add Last Modified Date to Single Blog Post Meta
function prefix_single_meta() {
	global $post;
	?>
		<ul>
		<li<?php oceanwp_schema_markup( 'author_name' ); ?>><i aria-hidden="true"></i><?php echo the_author_posts_link(); ?></li>
		<li><i aria-hidden="true"></i><?php the_category( ' <span>/</span> ', get_the_ID() ); ?></li>
		<li<?php oceanwp_schema_markup( 'modified_date' ); ?>><span aria-hidden="true"><?php echo get_the_modified_date(); ?></li>
		<li<?php oceanwp_schema_markup( 'publish_date' ); ?>><i aria-hidden="true"></i><?php echo get_the_date(); ?></li>
        </ul>
	<?php
}
add_filter('ocean_blog_single_meta','prefix_single_meta');

function prefix_entry_meta() {
	?>
		<ul>
		<li<?php oceanwp_schema_markup( 'author_name' ); ?>><i aria-hidden="true"></i><?php echo the_author_posts_link(); ?></li>
		<li><i aria-hidden="true"></i><?php the_category( ' <span>/</span> ', get_the_ID() ); ?></li>
		<li<?php oceanwp_schema_markup( 'modified_date' ); ?>><span aria-hidden="true"><?php echo get_the_modified_date(); ?></li>
		<li<?php oceanwp_schema_markup( 'publish_date' ); ?>><i aria-hidden="true"></i><?php echo get_the_date(); ?></li>
        </ul>
	<?php
}
add_filter('ocean_blog_entry_meta','prefix_entry_meta');

All PHP snippets should be added via a child theme's functions.php file.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.