Quick Review: Boxee Box
December 27, 2011 – 12:22 am | 3 Comments

Some of the technical issues with Boxee Box could have been fixed if the dev team was paying more attention to addressing the bugs rather than adding “features” of dubious value. In the final analysis, for the price and ease of use, Boxee Box is the best in its class and price range. You just need to be mindful of its limitations and buy it in hope of future improvements to its usability.

Read the full story »
Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » MySQL, WordPress

Remove Duplicate Posts in WordPress

Submitted by on December 5, 2009 – 10:28 pm2 Comments
Remove Duplicate Posts in WordPress

Below is the SQL script that will attempt to identify and remove duplicate posts in your WordPress database. This script can be useful for autoblogging. If you use plugins like WP-o-Matic to pull full-text RSS feeds into your database, you will inevitably end up with a bunch of duplicate articles. This is not good as many search engines – including Google – frown upon duplicate content and may decide not to index much of your site.

Edit the script and add your database information. You may need to change “wp_posts” to “_posts”. Before using the script, backup your database. There is no “undo” button in the script. If you are happy with the result, set up a cron job to run the script twice every day. Keep in mind that the script is looking for duplicate post titles. It does not look at the actual post content. Do not use this script if you purposefully have different posts with the same title.

#!/bin/ksh
 
MYSQL=/usr/bin/mysql
DBUSER=your_db_username
DBPASS=your_db_password
DBNAME=db_name
 
$MYSQL -u$DBUSER -p$DBPASS $DBNAME << EOF
 
        DELETE bad_rows.*
        from wp_posts as bad_rows
        inner join (
                select post_title, MIN(id) as min_id
                from wp_posts
                group by post_title
                having count(*) > 1
        ) as good_rows on good_rows.post_title = bad_rows.post_title
        and good_rows.min_id <> bad_rows.id ;
EOF

Popularity: 8% [?]

Related posts:

  1. Duplicating WordPress Installation
  2. WordPress Quick Upgrade for Linux
  3. WordPress Backup Script
  4. Passing MySQL Commands from Shell Script
  5. MySQL Global Search and Replace Script
  6. Improving WordPress Performance
  7. The correct MySQL GRANT syntax
  8. Creating print.css for WordPress
  9. Find largest files
  10. Generating complex SQL queries with shell scripts

2 Comments »

  • Sleeper Sofa says:

    well, i have troubles installing windows7 on my PC. maybe i need a bios update or something ~”*

    [Reply]

  • Jamie says:

    My RSS feeds create the duplicated titles for posts, but the date they are published differs. I need something that will look at the post title AND the date that title was published. If the title and date match another title and date, then I will know that it is a duplicate post.

    Can anyone help? I need something free because I am making this site for work and am not allowed to purchase things for it.

    [Reply]

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.