[ad_1]
Most likely, whatever front-end code your theme is using to show the post date is expecting a date format and could be doing some extra processing there. To know why that’s happening, we’d need to see the code that’s used to display it.
If you just want to run this in the backend (admin), you can use an is_admin() check in your filter to ensure that it’s only running on the admin side.
Can you please elaborate it more?
Hey @greenshady , I just took the help of ChatGPT and it get solved.
Revised snippet is:
function et_last_modified_date_blog( $the_date, $d, $post ) {
if ( 'post' === get_post_type( $post ) ) {
$the_time = get_post_time( 'His', false, $post );
$the_modified = get_post_modified_time( 'His', false, $post );
if ( $the_modified !== $the_time ) {
return sprintf( __( 'Last updated on %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y', false, $post ) ) );
}
}
return $the_date;
}
add_filter( 'get_the_date', 'et_last_modified_date_blog', 10, 3 );
Thanks for your reply. I am closing this thread now.
