2

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

3

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
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.