No more get_option(‘date_time’) in WordPress 5.5 using PHP 7.4?
Question
The template I’m using outputs the date of a post using:
echo get_the_date( get_option( 'date_time' ) );
I was wondering why this output is now (after upgrade to WP 5.5 and PHP 7.4) not working anymore?
A fast fix is using the option date_format
:
echo get_the_date( get_option( 'date_format' ) );
I looked into WordPress Developer https://developer.wordpress.org/reference/functions/get_the_date/#source looks like it suppose also to work when the option ‘date_time’ is empty:
function get_the_date( $format = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
if ( '' === $format ) { // <-- check for empty value
$the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
} else {
$the_date = get_post_time( $format, false, $post, true );
}
return apply_filters( 'get_the_date', $the_date, $format, $post );
}
Why does the output of get_the_date(get_option('date_time'))
in the template doesnt work with WordPress 5.5 (PHP 7.4)?
0
date-time, options, php, post-meta
3 years
2020-08-28T05:10:20-05:00
2020-08-28T05:10:20-05:00 0 Answers
51 views
0
Leave an answer