WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Importer
How to import multiline post metadata? (3 posts)

  1. vugluskra
    Member
    Posted 3 years ago #

    WordPress Importer failed to import post meta containig array of strings with line breaks.

    For example, after adding meta:

    $data = array(
      '1' => true,
      '2' => '1'."\n".'2'
    );
    add_post_meta($post_id, 'my_meta', $data);

    in the exported XML file i see:

    <wp:postmeta>
      <wp:meta_key>my_meta</wp:meta_key>
      <wp:meta_value><![CDATA[a:2:{s:1:"1";s:1:"1";s:1:"2";s:4:"1
    2";}]]></wp:meta_value>
    </wp:postmeta>

    But after importing, get_post_meta('my_meta',) returns null... After rmoving the line break all works as expected. Any ideas how to fix? Sorry for my english.

    http://wordpress.org/extend/plugins/wordpress-importer/

  2. Jon Cave
    WordPress Dev
    Plugin Author

    Posted 3 years ago #

    I will take a look. Thanks for reporting this.

  3. vugluskra
    Member
    Posted 3 years ago #

    Sorry for incorrect sample code... This issue presents only if metadata contains "Windows style" linebreaks (\r\n). After converting \r\n to \n, import works as expected.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic