Site logo

Archived topic

last modified date

5 replies · Started by mmarvel on January 10, 2018

Viewing posts 1–6 of 6

Hi.

i've seen a lot of discussion on this and tried similar to the discussion under "https://generatepress.com/forums/topic/displaying-last-updated-date-time-on-posts/"

I used the code in my functions.php

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' );

added this css
.last-updated {
font-size: small;
text-transform: uppercase;
background-color: #efefef;
}

It does work, but i didn't want to modify any of the pages.

Somehow i missed the part on how to control where this shows. I only wanted it on the posts. I want no date on my pages as they are static.

I'm sure you've answered this I'm just not locating the correct sequence of information.

Thanks. Martha

Hi

Thanks for the reply but that shows the original date and then the last modified with it in the same line. I just want the last modified. How do i actually have the last modified replace the original date?

Thanks. Martha

Add this CSS:

time.entry-date.published {
    display: none;
}

Thanks Leo.

That works perfect! Just what I was looking for.

B/r Martha

No problem.

This archived topic is closed to new replies.