这个自动分段机制,使用的是 wpautop() 函数,只会对文章内容和摘要生效,如果你希望禁用它,可以将下面的代码添加到主题的 functions.php 文件即可:
1 2 |
remove_filter( 'the_content', 'wpautop' ); //正文 remove_filter( 'the_excerpt', 'wpautop' ); //摘要 |
通常在源代码中显示如下图所示,虽然不影响前台显示,但是通不过W3C的标准。
通过条件标签来判断,在主题 functions.php 使用下面的代码:
以下通过get_post_type()判断只在类型为page的页面,删除content的p标签。
1 2 3 4 5 6 |
function remove_page_p(){ if(get_post_type() == 'page'){ remove_filter ( 'the_content' , 'wpautop' ); } } add_action ('loop_start', 'remove_page_p'); |