仔细检查输出后,所有没有显式结束标记的元素都缺少自结束符号,即<content ... />;
由于某种原因,functions.php 文件具有这些功能来“清理”HTML5 的输出:
/**********************************************
REMOVE SELF-CLOSING TAGS && USER-HARDCODED TAGS
***********************************************/
if ( !is_admin() && ( ! defined('DOING_AJAX') || ( defined('DOING_AJAX') && ! DOING_AJAX ) ) ) {
ob_start( 'html5_slash_fixer' );
add_action( 'shutdown', 'html5_slash_fixer_flush' );
}
function html5_slash_fixer( $buffer ) {
$buffer = str_replace( '<p id="top" />', null, $buffer );
$buffer = str_replace( ' />', '>', $buffer );
return $buffer;
}
function html5_slash_fixer_flush() {
ob_end_flush();
}
所以我在html5_slash_fixer_flush 方法中添加了一个检查,以确定当前查询是否针对提要:is_feed (WordPress Codex)
function html5_slash_fixer( $buffer ) {
$buffer = str_replace( '<p id="top" />', null, $buffer );
if( !is_feed() ){
$buffer = str_replace( ' />', '>', $buffer );
}
return $buffer;
}
使用此修复程序,输出验证仅包含警告。