Wordpress - 按帖子 ID 删除所有标签 [英] Wordpress - Delete all tags by Post ID
本文介绍了Wordpress - 按帖子 ID 删除所有标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个功能可以通过帖子 ID 添加标签,但现在我想在添加新标签之前删除该 ID 的所有当前标签?
I've got a function to add a tag by post ID, but now I would like to delete all the current tags for that ID before adding my new tags?
有没有人知道一个内置函数或 wordpress 查询来做到这一点?
Does anyone know a built in function or wordpress query to do this?
-哈德森
推荐答案
如果可以直接访问数据库(PhpMyAdmin),最快的方式是 SQL 请求.
If you can access the database directly (PhpMyAdmin), the quickest way is a SQL request.
查看代码中的数据库架构:
DELETE FROM wp_term_relationships
WHERE wp_term_relationships.object_id = 'yourPostId'
AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
AND wp_term_taxonomy.taxonomy = 'post_tag';
警告: 显然,直接修改数据库是危险的.这样做要小心.
WARNING : obviously, modifying directly the database is dangerous. Be careful doing that.
这篇关于Wordpress - 按帖子 ID 删除所有标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文