当我们安装主题和插件时,都会向…
大家在建设WordPress网站后相信在大量更新文章或者多人共同更新文章的时候有一个烦恼的问题存在,那就是可能时间长了会有部分重复标题甚至重复内容的文章出现,而我们却没有发现,这样就会有重复页面产生,影响我们的优化工作,那么下面WordPress主题资源网就分享一下关于WordPress删除重复文章一共有三种方法:
1. 插件:使用一款插件,名字叫做Delete Duplicate Posts
2. 通过操作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;
去除重复文章,一片都不保留
CREATE TABLE my_tmp AS Select ID AS col1 From wp_posts Where post_title In (Select post_title From wp_posts Group By post_title Having Count(*)>2); DELETE FROM wp_posts WHERE ID IN (SELECT col1 FROM my_tmp); DROP TABLE my_tmp;
另一种去除所有重复文章的方法
CREATE TABLE my_tmp AS Select ID AS col1 From wp_posts Where post_title In (Select post_title From wp_posts Group By post_title Having Count(*)>2);DELETE FROM wp_posts WHERE ID IN (SELECT col1 FROM my_tmp); DROP TABLE my_tmp;
操作方法很简单,只需将上面的SQL语句,放到自己网站数据库的 SQL框里,然后执行就可以了。(注意:操作之前,请先进行网站备份)
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);
保存以上代码以为delete.php,放在根目录,想要删除重复文章的时候,访问这个文件就可以了
微信扫描二维码联系我们!
我们在微信上24小时期待你的声音
提供外贸路由器设备产品,轻松翻墙,解答:WP主题推荐,WP网站建设,Google SEO,百度SEO,专业服务器环境搭建等!
需要提供WordPress主题/插件的汉化服务可以随时联系我们!另外成品WordPress网站以及半成品WordPress网站建设,海外Google SEO优化托管服务,百度SEO优化托管服务,Centos/Debian服务器WP专用环境搭建,WP缓存服务器搭建,我们都是你的首选,拥有多年WP开源程序服务经验,我们一直在坚持客户体验,没有最好,只有更好!