• Hi –

    I’ve placed the PHP code in my functions.php file to show the Last Updated Date on all posts.

    It works – but I’d like to find out if it’s possible to have the Last Updated Date information show up on the same line as the author’s name at the top of a post instead of where it currently sits? (For all posts – not just the one attached to the url I provided.) I’d like the new date to be immediately visible to a visitor – and I can’t seem to get the Last Updated Date to show up in a Google Search – so I’m trying to get it up higher on the page for those people who do open the post.

    I’m using the Virtue Child theme.

    Here’s the code I added to functions.php file:

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

    I’m not sure if this code needs “tweaking” or if there is something I am overlooking in the theme options. I’d love some advice ??

    Thank you!

    Meagan

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • hannah

    (@hannahritner)

    Hi Meagan,
    The following css would move your updated date above the title:

    .single-post p.last-updated {
        position: absolute;
        top: -10px;
    }

    Just paste that into your custom css box in Theme Options. Does it work for you?

    Hannah

    Thread Starter Maggie96

    (@maggie96)

    Hi Hannah,

    That moved it up above the post title.

    So – thank you!!

    Meagan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to show Last Updated Date on a post?’ is closed to new replies.