SQL function to copy a custom field to the post_content en mass in for wordpress

custom-fields mysql sqlbulkcopy wordpress

Question

I need to copy the contents of key value for the key post_content to another table called wp_posts into the key values for post_content.

Is there anyway to do this in bulk, like all posts in the database? This would help me greatly, thank you.

Popular Answer

Assuming your first post_content is in wp_postmeta (a custom field). Then you would copy from the wp_postmeta to the wp_posts;

UPDATE wp_posts,wp_postmeta 
SET wp_posts.post_content = wp_postmeta.meta_value 
WHERE wp_posts.ID = wp_postmeta.post_id 
AND wp_postmeta.meta_key='abstract'


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why