wpautop() 控制文章内容是否自动换行

WordPress默认方法输出内容时,会为编辑器内换行的内容自动加上<p>标签。

如果想去掉这个功能,可使用

remove_filter( 'the_content', 'wpautop' );

而有时,例如用了$post->post_content会使这个功能失效,若想还原,可这样写

$content = $post->post_content;
$content = wpautop( $content );

同理可处理摘要the_excerpt()及评论内容comment_text().

我们将24小时内回复。
2023-05-31 03:48:02
您好,有任何疑问请与我们联系!
您的工单我们已经收到,我们将会尽快跟您联系!
取消

选择聊天工具: