After adding “Last Update date”, error in date on user profile

[ad_1]

Most likely, whatever front-end code your theme is using to show the post date is expecting a date format and could be doing some extra processing there. To know why that’s happening, we’d need to see the code that’s used to display it.

If you just want to run this in the backend (admin), you can use an is_admin() check in your filter to ensure that it’s only running on the admin side.

Can you please elaborate it more?

Hey @greenshady , I just took the help of ChatGPT and it get solved.

Revised snippet is:

function et_last_modified_date_blog( $the_date, $d, $post ) {
    if ( 'post' === get_post_type( $post ) ) {
        $the_time = get_post_time( 'His', false, $post );
        $the_modified = get_post_modified_time( 'His', false, $post );
        
        if ( $the_modified !== $the_time ) {
            return sprintf( __( 'Last updated on %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y', false, $post ) ) );
        }
    }
    return $the_date;
}

add_filter( 'get_the_date', 'et_last_modified_date_blog', 10, 3 );

Thanks for your reply. I am closing this thread now.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer