Why do I lose all the slashes, i.e., ” \ “, in my blogs when I import XML files by the WordPress Importer plug-in?

The importer calls wp_insert_post() which runs stripslashes_deep() on the data. But the exporter doesn’t run addslashes. Looks like a bug to me.

What you may try is to prepare the data during export.

Create a plugin with the following content and activate it before you run the export:

<?php
/**
 * Plugin Name: Slash my export
 * Description: Adds extra back slashes to exported data.
 */

add_filter( 'the_content_export', 'addslashes' );
add_filter( 'the_excerpt_export', 'addslashes' );

I have not tested this, it may be wrong, it may have side effects. stripslashes_deep() may eat the extra slashes too …

You should open a bug on Trac if this plugin fixes your problem.

Leave a Comment