WordPress 刪除重複文章一共有三種方法:
1. 外掛:使用一款外掛,名字叫做 Delete Duplicate Posts
2. 運算元據庫:
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;
DELETE FROM wp_posts WHERE ID NOT IN (SELECT col1 FROM my_tmp);
DROP TABLE my_tmp;
3.php 程式刪除
require('./wp-load.php');
$strsql="create table my_tmp as select min(ID) as col1 from cd_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);
$strsql="create table my_tmp as select min(ID) as col1 from cd_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);
儲存以上程式碼以為 delete.php,放在根目錄,想要刪除重複文章的時候,訪問這個檔案就可以了