最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Assign all Post in Wp to a specific Category

programmeradmin0浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1
  1. Find 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)

  2. 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.

发布评论

评论列表(0)

  1. 暂无评论