My development site has posts with custom fields. Meanwhile my live site has more posts added while I'm working on my development site. Now I want to export posts with specific custom fields from live site and import those posts to my development site.

I do not want to do this using WP export/import tool. I want to do this by sql.

That means I will export tables from live site and import those to my development site. Keep in mind that I want specific custom fields.

My questions are :

What should be the best approach do achieve this goal???

Which tables do I need to export from the live site???

What should I do about post authors and post terms???

Thanks In Advance

1 Answer 1


Hi The tables that you need to consider is

wp_posts - Which contains all the details about the posts. wp_postmeta - Which is used to store the meta details for a post with relation to post_id.

Query will be

Select * FROM wp_posts a, wp_postmeta b WHERE a.post_status = 'published' AND a.post_id = b.post_id AND b.meta_key = 'Your Custom Field';

wp_terms, wp_term_relationships contains the terms and tags which is related to a particular post.

wp_terms - tag details. wp_term_relationships - how each term is related to a particular post. (object_id = post_id)

Cheers Happy Coding.

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.