Support » Developing with WordPress » Last updated date function

  • Resolved 凱寧

    (@kennyateam990)


    I want to show the “last updated date” on the front of the post and page.
    so I add the following code in the 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" style="text-align:right">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
    }
        $custom_content .= $content;
        return $custom_content;
    }
    
    add_filter( 'the_content', 'wpb_last_updated_date' );

    It works,it show on every page.
    but I don`t want to show it on my home page.
    How can I do ?

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Last updated date function’ is closed to new replies.