WordPress删除数据中标题重复文章的方法
https://www.shanhubei.com/archives/55144.html
慎用!!! 用之前一定要备份 备份 备份
一种是删除重复的方法是:使用插件,大家可以去官网上下载
二种删除重复的方法是:登录数据库,使用sql语句删除,具体的语句为如下代码:
CREATE TABLE my_tmp AS SELECT MIN(ID) AS col1 FROM wp_posts GROUP BY post_title;
DELETE FROM wp_posts WHERE ID NOT IN (SELECT col1 FROM my_tmp);
DROP TABLE my_tmp;
但是由于插件容易是wordpress的速度变慢我还是舍弃了他,另外直接操作数据库,还需要登陆数据库比较麻烦,所以我综合以上代码写了一个php文件,代码如下
require('./wp-load.php'); $strsql="create table my_tmp as select min(ID) as col1 from wp_posts group by post_title"; $strsql1="delete from cd_posts where ID not in (select col1 from my_tmp)"; $strsql2="drop table my_tmp"; $result=mysql_query($strsql); $result=mysql_query($strsql1); $result=mysql_query($strsql2);