I Cleared off all data in wordpress wp_postmeta, wp_terms, wp_term_relationship, wp_term_taxonomy.
I have post content of 50k. Is there any way I can assign all the 50 posts to a new Category I just created, I will recommend using.?
I Cleared off all data in wordpress wp_postmeta, wp_terms, wp_term_relationship, wp_term_taxonomy.
I have post content of 50k. Is there any way I can assign all the 50 posts to a new Category I just created, I will recommend using.?
Share Improve this question edited Jun 1, 2019 at 22:48 Godwin Alex Ogbonda asked Aug 10, 2018 at 8:46 Godwin Alex OgbondaGodwin Alex Ogbonda 1192 silver badges13 bronze badges1 Answer
Reset to default 1Find out the ID of the category that you want to assign. You'll see it in the URL when editing the category (URL will be something like
?taxonomy=category&tag_ID=3&post_type=post
, here 3 is the ID)Assuming that the ID is 3, you can now run this query in your database (eg via PHPMyAdmin)
INSERT IGNORE INTO wp_term_relationships (object_id, term_taxonomy_id) ( SELECT DISTINCT ID, 3 FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' );
If you use a different prefix than wp_
, be sure to change it. Also change the 3 to the ID you want.