Alter the Blog Post Published Date to Last Modified Date
Important
You no longer need to use custom code for this, the option is now available directly from the Customizer for the default blog layout or in the Post Meta element when creating a dynamic template for your blog post design.
The following snippet can be used to modify the default published date in the theme's post meta to display the last modified date instead.
function myprefix_modify_blog_meta_blocks( $blocks ) {
if ( is_array( $blocks ) && isset( $blocks['date'] ) ) {
$blocks['date'] = function() {
$icon = wpex_get_theme_icon_html( 'clock-o' );
echo $icon . 'Updated on ' . esc_html( get_the_modified_date( get_option( 'date_format' ) ) );
};
}
return $blocks;
}
add_filter( 'totaltheme/blog/meta_blocks/entry_blocks', 'myprefix_modify_blog_meta_blocks' );
add_filter( 'totaltheme/blog/meta_blocks/singular_blocks', 'myprefix_modify_blog_meta_blocks' );All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
We recommend Code Snippets (100% Free) or WPCode (sponsored)
Related Snippets