如何使用<p>和<?

时间:2017-05-17 13:42:23

标签: php wordpress csv export-to-csv

我正在使用WP All Export插件创建我的帖子的自定义导出为CSV。但是,帖子内容中没有一个包含<p><br>标记,它只是空格。我需要标签,因为我正在导入不同类型的CMS,不会将空格视为中断。

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

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

但这只显示WYSIWYG编辑器中的标签。数据库中的内容具有空格。我可以在导出时运行PHP函数,在我的内容中包含P和BR标记吗?

2 个答案:

答案 0 :(得分:1)

<?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/

答案 1 :(得分:0)

您可以通过遵循accepted answer here来实现此目的,即使认为它未经测试也可以工作。

不过先备份该数据库!

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

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

中包含标签