给wordpress的文章导入标签对应的标签
网络科技
0
第一步,如右图,找到wp_terms表,我们在整理数据时,关键词如果重复,将不会被插入,即使用现有关键词,如果slug 也就是别名重复,该关键词将不会被插入,所以别名一定不要与已有的slug字段中的值相同。
第二三四步,在插入公式表中,整理我们关键词,前往执行我们的SQL即可。
插入SQL
INSERT INTO `wp_terms`( `name`, `slug`, `term_group`) select a.name,a.slug,0 from (select '大家' name, 'dj' slug ) a left join wp_terms b on a.name=b.name or a.slug=b.slug where b.name is null ;INSERT INTO `wp_term_taxonomy`( `term_id`, `taxonomy`, `description`, `parent`, `count`) select a.term_id,'post_tag', '', 0, 1 from wp_terms a left join wp_term_taxonomy b on a.term_id=b.term_id where a.name='大家' and b.term_id is null ;INSERT INTO `wp_term_relationships`(`object_id`, `term_taxonomy_id`, `term_order` ) select cc.ID,aa.term_taxonomy_id, 0 from wp_term_taxonomy aa inner join wp_terms bb on aa.term_id=bb.term_id inner join ( select a.ID from wp_posts a inner join wp_term_relationships b on a.ID=b.object_id inner join wp_term_taxonomy c on b.term_taxonomy_id=c.term_taxonomy_id where c.taxonomy='category' and a.post_status='publish' and ( a.post_title like '%大家' or a.post_content like '%大家%' ) ) cc on 1=1 left join wp_term_relationships dd on dd.object_id=cc.id and dd.term_taxonomy_id=aa.term_taxonomy_id where bb.name='大家' and dd.object_id is null ;
在执行完插入后请执行数量更新:
update wp_term_taxonomy a inner join (select term_taxonomy_id,count(*) sl from wp_term_relationships group by term_taxonomy_id ) b on a.term_taxonomy_id=b.term_taxonomy_id set a.count=b.sl
给wordpress的文章导入标签对应的标签excel文档下载:点击下载
版权声明:除非特别标注原创,其它均来自互联网,转载时请以链接形式注明文章出处。