Search code examples
phpwordpresscsvexport-to-csv

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


I'm using the WP All Export plugin to create custom exports of my posts into CSV. However, none of the post content has <p> or <br> tags, it's just white spaces. I need the tags because I'm importing into a different type of CMS that doesn't treat white space as breaks.

I played around with adding and removing the following in functions.php:

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

But that only shows the tags within the WYSIWYG editor. The content in the database has white space. Is there a PHP function I can run on my export to include the P and BR tags on my content?


Solution

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

    You could use the_content filter or your own custom filter. https://developer.wordpress.org/reference/functions/apply_filters/

    In functions.php:

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