By default, WordPress doesn’t include any <p> tags in the XML export. However, sometimes that would be the desired behavior – for example when migrating data to another system that does not automatically add paragraph tags.
The solution is actually quite simple. During export, run the exported content through same wpautop() function that’s used when displaying posts.
function codelight_content_export($content) { return wpautop($content); } add_filter('the_content_export', 'codelight_content_export', 999);
Add this to your functions.php and you’re set.
Note that you may want to do the same for your excerpts, in which case you should use the_excerpt_export filter.
4 Responses to “Exporting WordPress posts and pages with paragraph tags included”
James
Thanks for your post, it was very helpful.
Note: we had to put the add_filter(….) line in the wp-admin\includes\export.php file for it to work. We put it below the other add_filter at line 345.
The function codelight_content_export() we placed at the end of the wp-includes\functions.php file and the export worked great!
Thanks again!
James
brnteka
yep thanks for the post, placed it in functions.php and it worked as expected
pHghost
Hello, I’m wondering, is there any way to do this with my blog on WordPress.com?
As far as I am aware, you cannot run functions during expert there.
Would be a ton of help!
Indrek Kõnnussaar
Sorry, no idea about wordpress.com, never used it.