解决WP文章页出现的W3C HTML5问题

提醒:本文最后更新于 2643 天前,文中所描述的信息可能已发生改变,请仔细核实。


最近发现有人用W3C在检查我的网站。。

自己也去看看。发现主页、文章页居然有问题。

所以就解决下,到最后发现还有下面这个问题:

No p element in scope but a p end tag seen.

查了下,是wpautop的问题,但又不可能不要用wpautop。

用W3C看了下源码,发现是加p标签自动完成的位置不对。晕死。

想了下,用了个土办法解决。不保证解决所有文章的这个问题,但解决大部分的。

//延迟加载wpautop(for w3c)
//No p element in scope but a p end tag seen.
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 999);
remove_filter( 'the_excerpt', 'wpautop' );
add_filter( 'the_excerpt', 'wpautop' , 999);
remove_filter( 'comment_text', 'wpautop' );
add_filter( 'comment_text', 'wpautop' , 999);

不知有没有遇到过这问题的伙计们,给点意见。

初步想法是,以后写文章,自己加p标签。。。(好麻烦)或者每行用个shortcode。。。(凌乱)

没有任何主意了。

转载请注明转自:kn007的个人博客的《解决WP文章页出现的W3C HTML5问题