[Resolved] last modified date

Home Forums Support [Resolved] last modified date

Home Forums Support last modified date

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #467769
    mmarvel

    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

    #467958
    Leo
    Staff
    Customer Support

    Hi there,

    The function is actually not required.

    All you should need is Tom’s CSS here: https://generatepress.com/forums/topic/displaying-last-updated-date-time-on-posts/#post-434328

    Let me know if this helps 🙂

    #468338
    mmarvel

    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

    #468514
    Leo
    Staff
    Customer Support

    Add this CSS:

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

    Thanks Leo.

    That works perfect! Just what I was looking for.

    B/r Martha

    #470893
    Leo
    Staff
    Customer Support

    No problem.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.