如何使用 <p> 和 <br> 将 Wordpress post 内容导出到 csv 中?

How can I export Wordpress post content into csv with <p> and <br>?

我正在使用 WP All Export 插件创建我的 post 到 CSV 的自定义导出。然而,post内容的none有<p><br>标签,只是白色的space。我需要这些标签,因为我正在导入一种不将白色 space 视为中断的不同类型的 CMS。

我尝试在 functions.php 中添加和删除以下内容:

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

但这只显示所见即所得编辑器中的标签。数据库中的内容有白色space。是否有 PHP 功能可以让我在导出时 运行 在我的内容中包含 P 和 BR 标签?

<?php echo apply_filters( 'filter_name', $body ); ?>

您可以使用 the_content 过滤器或您自己的自定义过滤器。 https://developer.wordpress.org/reference/functions/apply_filters/

在functions.php中:

add_filter( 'custom_filter_name', 'wpautop'); https://developer.wordpress.org/reference/functions/add_filter/

您可以通过遵循 accepted answer here 来实现这一点,即使它说它未经测试,它仍然有效。

先备份那个数据库!

将代码添加到您的活动主题 functions.php 并单击 Wordpress 后端中的任何 link。该代码将 运行。然后删除 functions.php.

中的代码

这将使用通常用于输出到屏幕的段落标签更新数据库中的内容。当您 运行 导出时,您将在 .csv

中拥有标签