What is the required format for importing posts into WordPress?

I have several posts in an Microsoft Excel file (.csv/.xls). I want to know the appropriate format of the file to import into WordPress.com.

Note: I do not need help to convert the csv format into xml. I just need to know the required format for feeding into WordPress. Same approach should work for .org hosted blogs.

Read More

Currently I have extracted a WordPress XML file from WordPress with the necessary headers. I believe all I need to do is populate the below XML code for each new post.

What fields can be excluded? What fields can be left blank? An example of successfully imported file and code would be appreciated.

I have tried two imports into WordPress that have been confirmed as successful however I cannot see either post? So I suspect something is wrong with my file.

 <Item>     
      <title>   My Post Title   </title>
      <link>    My Post URL </link>
      <pubDate> Sun, 01 Jan 2012 00:00:00 +0000 </pubDate>
      <dc:creator>  Author  </dc:creator>
      <guid isPermaLink="false">    My Post WP URL  </guid isPermaLink="false">
      <description> My Post Description </description>
      <content:encoded> My Post Content </content:encoded>
      <excerpt:encoded> My Post Excerpt </excerpt:encoded>
      <wp:post_id>  My Post ID  </wp:post_id>
      <wp:post_date>    2012-01-01 00:00:00 </wp:post_date>
      <wp:post_date_gmt>    2012-01-01 00:00:00 </wp:post_date_gmt>
      <wp:comment_status>   Open    </wp:comment_status>
      <wp:ping_status>  Open    </wp:ping_status>
      <wp:post_name>    My Post Title   </wp:post_name>
      <wp:status>   inherit </wp:status>
      <wp:post_parent>  My Post Parent ID   </wp:post_parent>
      <wp:menu_order>   0   </wp:menu_order>
      <wp:post_type>    attachment  </wp:post_type>
      <wp:post_password>        </wp:post_password>
      <wp:is_sticky>    0   </wp:is_sticky>
      <wp:attachment_url>       </wp:attachment_url>
 </Item>        

Related posts

Leave a Reply

2 comments

  1. Here is an import file where only a few settings are used (although you may be able to exclude even more), which successfully imports three posts (tested on WP 4.2.2):

    <?xml version="1.0" encoding="UTF-8" ?>
    <rss version="2.0"
        xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
        xmlns:content="http://purl.org/rss/1.0/modules/content/"
        xmlns:wfw="http://wellformedweb.org/CommentAPI/"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        xmlns:wp="http://wordpress.org/export/1.2/" >
    
        <channel>
            <wp:wxr_version>1.2</wp:wxr_version>
    
            <item>
                <title>My first post</title>
                <dc:creator><![CDATA[admin]]></dc:creator>
                <description></description>
                <content:encoded><![CDATA[
    <p>Welcome to my first post!</p>
    ]]></content:encoded>
                <excerpt:encoded><![CDATA[]]></excerpt:encoded>
                <wp:post_date>2015-03-01 16:20:00</wp:post_date>
                <wp:status>publish</wp:status>
                <wp:post_type>post</wp:post_type>
            </item>
    
            <item>
                <title>My second post</title>
                <dc:creator><![CDATA[admin]]></dc:creator>
                <description></description>
                <content:encoded><![CDATA[
    <p>Welcome to my second post!</p>
    ]]></content:encoded>
                <excerpt:encoded><![CDATA[]]></excerpt:encoded>
                <wp:post_date>2015-03-02 16:20:00</wp:post_date>
                <wp:status>publish</wp:status>
                <wp:post_type>post</wp:post_type>
            </item>
    
            <item>
                <title>My third post</title>
                <dc:creator><![CDATA[admin]]></dc:creator>
                <description></description>
                <content:encoded><![CDATA[
    <p>Welcome to my third post!</p>
    ]]></content:encoded>
                <excerpt:encoded><![CDATA[]]></excerpt:encoded>
                <wp:post_date>2015-03-03 16:20:00</wp:post_date>
                <wp:status>publish</wp:status>
                <wp:post_type>post</wp:post_type>
            </item>
    
        </channel>
    </rss>
    
  2. If you just need a known-good example of a WordPress XML import file, try the Theme Unit Test data XML file.

    If the code in your Excel file is well-formed, you may also look at other options, such as importing (X)HTML.

    If you want to see how WordPress actually constructs its “Extended RSS” (XML) file, see wp-admin/includes/export.php.

    If you want to see how WordPress imports data, see wp-admin/includes/class-wp-import.php and the import plugin‘s wordpress-importer.php and parsers.php.

    As for what data are actually required, I would assume that it is just anything that is a primary key in the database. But double-check the above two files to be sure.