WordPress怎么禁用文章自动添加p标签

追格官方小助手/ 2022年03月20日/ WordPress/ 浏览 1483

WordPress在发布文章时,会自动在内容中插入p标签,在使用html标签写内容时会自动插入<p></p>,那么WordPress怎么禁用文章自动添加p标签呢?


将下面代码添加到当前WordPress模板函数functions.php中:


remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');


上面一个是文章内容过滤,一个是摘要内容过滤p标签。


当然,我们也可以在 single.php 中使用 get_the_content() 输出文章内容:


echo get_the_content();


发表评论

暂无评论,抢个沙发...

客服 工单