I’ve added the following function (copied from a website) which displays the date and time of the latest post/page update on every post/page. It works great, but I’d like to prevent it from displaying on the homepage. Please help.

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

1 Answer
1

Use is_front_page() and bail at the start of the function if true:

function wpb_last_updated_date( $content ) {
    if ( is_front_page() ) {
        return $content;
    }

    // Rest of your function
}

Leave a Reply

Your email address will not be published. Required fields are marked *