WordPress删除数据中标题重复文章的方法

慎用!!!  用之前一定要备份 备份 备份

一种是删除重复的方法是:使用插件,大家可以去官网上下载

二种删除重复的方法是:登录数据库,使用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);

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_55144.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?