好吧,我发现了问题,就像我想的那样。问题是get_option( \'date_time\' )
仅返回false
.
职能发生了变化get_the_date()
.
在Wordpress中5.4 在general-template.php:
function get_the_date( $format = \'\', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
if ( \'\' == $format ) {
$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 );
}
自Wordpress
5.5 这个
general-template.php 看起来是这样的:
function get_the_date( $format = \'\', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
if ( \'\' === $format ) {
$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 );
}
区别在于类型true比较运算符
// Wordpress 5.4
if ( \'\' == $format )
// vs
// Wordpress 5.5
if ( \'\' === $format )
错误修复
我认为正确的解决方案是检查并清空或
false
$format
. 诸如此类:
if ( \'\' === $format || false === $format )