Hi there,
I’m trying to display the last updated date at the top of my blog posts. I’m using the code:
function wpb_last_updated_date( $content ) {
$u_time = get_the_time(‘U’);
$u_modified_time = get_the_modified_time(‘U’);
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time(‘F jS, Y’);
$updated_time = get_the_modified_time(‘h:i a’);
$custom_content .= '
Last updated on ‘. $updated_date . ’ at ‘. $updated_time .’
’;}
$custom_content .= $content;
return $custom_content;
}
add_filter( ‘the_content’, ‘wpb_last_updated_date’ );
However, it is adding a last updated date to pages AND posts. Do you know what I am missing so it only shows on posts?
Thank you!