批量删除不受欢迎的标签 [英] Mass delete unpopular Tags

查看:29
本文介绍了批量删除不受欢迎的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

批量删除不受欢迎的标签

Mass delete unpopular Tags

我有 1000 个标签,我想简单地删除所有使用次数不超过 X 次的标签......即 5 次.

I have 1000's of tags and I would like to simply delete all tags that aren't used more than X times... i.e. 5 times.

有谁知道一个简单的方法来做到这一点?即使是直接的 SQL 也会完全摇滚!

Does anyone know of a simple way to do this? Even straight SQL would totally ROCK!

推荐答案

$x = 5; // set this to any number
$sql = "SELECT `name` FROM `wp_terms`";
$result = mysql_query($sql);
$count = array();
while($row = mysql_fetch_assoc($result))
{
  $count[$name]++;
}
foreach($count as $key = $value)
{
  if($value < $x)
    {
      $sql2 = "DELETE FROM `wp_terms` WHERE `name` = '". $key ."'";
      $result2 = mysql_query($sql2);
    }
}

有更有效的方法可以做到这一点,但这会完成工作.

There's more efficient ways of doing it but this will do the job.

先备份.我不完全确定该表是否专供标签使用.

make a backup first. I'm not entirely sure that that table is exclusive to tags.

这篇关于批量删除不受欢迎的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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