Post updated date
-
Hi,
I have added a PHP function shown in a blog to my functions.php (child theme) to display last updated time to my blog posts. But it started showing the last updated time to my Home page. I tried a few codes to skip home page like
if (is_page(2020)) return;but didn’t solve the issue. How can I only display this for posts?Another thing; I want the last updated date to display in Google Results. What is the best way to do it? I saw this thread discussing that issue, but I couldn’t understand which one I should change.
The code I added to display updated time:
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 .= '<p class="last-updated">Last updated on '. $updated_date . ' at '. $updated_time .'</p>'; } $custom_content .= $content; return $custom_content; } add_filter( 'the_content', 'wpb_last_updated_date' );The page I need help with: [log in to see the link]
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
The topic ‘Post updated date’ is closed to new replies.
