Question

I'm trying to import data for a custom post type:

<item>
                <title>sausages</title>
        <link>http://localhost:10293/?gmc_recipeingredient=sausages</link>
        <pubDate>Tue, 18 Mar 2014 21:18:03 +0000</pubDate>
        <dc:creator><![CDATA[KevinUK]]></dc:creator>
        <guid isPermaLink="false">http://localhost:10293/?gmc_recipeingredient=sausages</guid>
        <description></description>
        <content:encoded><![CDATA[]]></content:encoded>
        <excerpt:encoded><![CDATA[]]></excerpt:encoded>
        <wp:post_id>123</wp:post_id>
        <wp:post_date>2014-03-18 21:18:03</wp:post_date>
        <wp:post_date_gmt>2014-03-18 21:18:03</wp:post_date_gmt>
        <wp:comment_status>open</wp:comment_status>
        <wp:ping_status>open</wp:ping_status>
        <wp:post_name>sausages</wp:post_name>
        <wp:status>publish</wp:status>
        <wp:post_parent>112</wp:post_parent>
        <wp:menu_order>1</wp:menu_order>
        <wp:post_type>gmc_recipeingredient</wp:post_type>
        <wp:post_password></wp:post_password>
        <wp:is_sticky>0</wp:is_sticky>
        <wp:postmeta>
            <wp:meta_key>gmc-ingredientquantity</wp:meta_key>
            <wp:meta_value><![CDATA[2]]></wp:meta_value>
        </wp:postmeta>
    </item>

The post_parent is 112 but once I import and look in the wp_posts table, the record has 0 as the post_parent even though a post with id 112 exists.

It's correctly adding the record to wp_posts and wp_postmeta so why is not adding a value for post_parent? All the other fields look like that have been populated correctly.

Was it helpful?

Solution

I found this information in a plugin (https://wordpress.org/plugins/wp-re-importer/faq/)

The standard WordPress Importer only sets a post's post_parent if that post also exists in the import; it can't map an imported post to a post that already exists in the database.

When I exported 'all content' instead then my snippet in my question successfully shows.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top