0

Alright here is the problem... we have posts that are missing a custom field. We just recently received the values for that field.

Is there a way via phpmyadmin to insert in to the table post_meta a custom field named "translation" and then the value for each post already published?

I am trying to avoid having to go back to each post and adding this custom field one by one.

Thanks!

2 Answers 2

2

Yes, it's doable ... but tricky. You'll have to run an INSERT script on the wp_postmeta table. Remember, the table has three columns: post_id, meta_key, and meta_value.

So if you know the ID of the post and the meta value you want to set, you'd run the following query:

INSERT INTO `wp_postmeta` (post_id, meta_key, meta_value) VALUES (*ID*, 'translation', *VALUE*;

Where *ID* is the id of the post you're attaching the value for and *VALUE* is the meta value of the "translation" field.

Like I said, doable ... but you'll need a separate INSERT query for each post. You could dump all of these into a single text file and run the entire set in one pass if you want, otherwise it might take as much time as it would to just add the key through the WordPress UI in the first place.

Sign up to request clarification or add additional context in comments.

1 Comment

Alright i'll try this and let you know how this works out. Yeah I was a little confused as to how to map that value with the proper post ID.
0

You can easily add the column with phpMyAdmin, but you're probably going to have the read the data with some sort of code and iterate through updating the values. PhpMyAdmin isn't really the best tool for importing data that's not already in .sql format.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.