4

I'm creating a custom import script to migrate CSV data into wordpress. Each post has a series of attachments that must come with it.

Following chapter 14 (importing via a custom mysql script) in the book Wordpress Professional Development (1st edition), Everything is importing fine, except the book does not explain how to get attachments into posts.

I can see my custom posts in wp_posts, and I can see the attachment post_type. But I can't see how the two are related.

I'm assuming that I'm going to have to save the post first, get the id, and then use that somehow in a relationship with the attachment.

What would be the workflow here (if that's incorrect)? Can you provide an example insert statement(s) that demonstrate how to use sql to get a post into Wordpress?

1 Answer 1

4

The post that an attachment is related to is determined by the post_parent column on the wp_posts table (depending on your database prefix). Set it to the post_ID of the parent post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.