Support » Plugin: Import any XML or CSV File to WordPress » Parent/Child Post relationships

  • Resolved Duffdaddy

    (@duffdaddy)


    Can you preserve or create parent/child post relationships? I’m not talking about categories.
    I’m using the Toolkit plugin and we’re using its parent/child relationship set-up and I’d like to preserve those automatically on import.
    Is there away to do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @duffdaddy

    I’m using the Toolkit plugin and we’re using its parent/child relationship set-up and I’d like to preserve those automatically on import.

    I’d need to see how the Toolkit relationship data is stored in the database to advise on this. Please replicate your set up at http://www.wpallimport.com/debug/ and open a support ticket at http://www.wpallimport.com/support/ so that we can take a look. Be sure to include a link to this ticket for reference.

    Thread Starter Duffdaddy

    (@duffdaddy)

    Toolkit uses the Post ID of the parent and stores it in the child as “_wpcf_belongs_ParentName_id”.
    I’ll set up a copy as you’ve asked. Maybe we could use your PHP script inclusion to simply look up the parent ID when we import the child and pop it into the child record as its created?
    I’m probably talking out my arse as I have no idea, but just a thought.

    • This reply was modified 4 years, 10 months ago by Duffdaddy.
    Plugin Author WP All Import

    (@wpallimport)

    Hey @duffdaddy

    Yes, your solution sounds good. If you’re also defining them as the parent posts in WordPress itself (which you can do in the “Other Options” section of the import), then you could use a script like this:

    add_action( 'pmxi_saved_post', 'my_set_parent', 10, 3 );
    
    function my_set_parent( $post_id, $xml, $is_update ) {
    	if ( $parent = wp_get_post_parent_id( $post_id ) ) {
    		update_post_meta( $post_id, '_wpcf_belongs_ParentName_id', $parent );
    	}
    }
    Plugin Author WP All Import

    (@wpallimport)

    Marking this as resolved, but feel free to respond here if you’re still having issues or still have questions regarding this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Parent/Child Post relationships’ is closed to new replies.