CnSwift - 雨燕

agile development - 敏捷开发

wordpress删除重复标题文章的方法

wordpress删除重复标题文章的方法

1、使用插件 Delete Duplicate Posts

2、使用 mysql 管理工具执行下面的 sql 语句

1
2
3
4
5
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;

3、写一个 PHP 文件,取名 delete.php。上传至网站根目录,打开浏览器运行
http://www.域名/delete.php

代码如下:

1
2
3
4
5
6
7
8
9
<?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 wp_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);
?>

注意:按照以上方法执行,可能会出现菜单不显示。检查发现进入wordpress后台,点击文章-》分类目录,重新编辑所有分类目录,然后去外观-》菜单,重新编辑菜单即可。

感谢赞赏.

Welcome to my other publishing channels