标记所有 Wordpress 帖子 [英] Tag all Wordpress posts

查看:39
本文介绍了标记所有 Wordpress 帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了几个小时,无论是寻找插件还是一些看起来安全的 SQL 来执行此操作,但似乎没有什么正是我需要的......

I've been searching for hours, either for a plugin or some safe looking SQL to do this, but nothing seems to be exactly what I need...

我有一个包含大约 32,000 个帖子的 Wordpress 网站,我们使用各种标签来帮助管理后端(即,在任何人评论过多使用相同的标签).这些帖子中约有 30,000 篇包含新"标签,但我们现在需要标记剩余的约 2,000 篇以匹配.

I have a Wordpress site of approximately 32,000 posts, and we use various tags to help with administration on the back end (i.e. they're not visible on the front end or used for SEO, before anybody comments on too much usage of the same tag). About 30,000 of these posts include the tag 'new', but we need to now tag the remaining ~2,000 to match.

WP 管理面板并不能真正完成这项任务 - 需要几天时间才能完成并将标签应用于 2,000 个帖子.似乎存在各种插件,但它们并没有真正做到他们在描述中声称的那样.我能找到的唯一似乎有用的 SQL 假设标签是新的,并且我想将它应用于单个类别中的所有帖子.我想我可以删除现有标签(同样,Wordpress 的管理面板不是一项有趣的任务——它通常在大约 30 个帖子后崩溃,这意味着有人必须一遍又一遍地点击按钮),然后运行 ​​SQL 来应用一个新的.

The WP administration panel isn't really up for the task - it would take somebody days to go through and apply a tag to 2,000 posts. Various plugins seem to exist but they don't really do what they claim in the descriptions. And the only SQL I could find that seemed helpful assumes that the tag is new and that I want to apply it to all posts in a single category. I suppose I could delete the existing tag (again, not a fun task with Wordpress' admin panel - it generally crashes after about 30 posts meaning somebody has to sit clicking the button over and over) and then run the SQL to apply a new.

有人能指出我正确的方向吗?

Can somebody point me in the right direction please?

推荐答案

您可以对所有帖子运行循环并使用 wp_set_object_terms() 添加所需的标签:

You could run a loop over all of your posts and use wp_set_object_terms() to add the desired tag:

http://codex.wordpress.org/Function_Reference/wp_set_object_terms

这篇关于标记所有 Wordpress 帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆