1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question about this plugin - Super Post Cleaner

Discussion in 'Blogging' started by maineyak, Jan 25, 2014.

  1. maineyak

    maineyak Power Member

    Joined:
    Mar 27, 2008
    Messages:
    600
    Likes Received:
    555
    I've used this plugin on many sites, and it works fine. It stops duplicate posts from being created, but the site I'm working on now is a pinterest clone, and it won't work with repins. The plugin is no longer supported, is why I'm here asking. Could this be made to work on only one category? I have one category that works as the blog, the rest of the categories are for the pinterest side of the site

    Code:
    function superPostCleaner(){
    
        global $wpdb;
    
        $prefix = $wpdb->prefix;
    
    
    
        $wpdb->query("DELETE a.* 
    
            FROM ".$prefix."posts AS a 
    
            INNER JOIN (SELECT Greater1.post_title, Titles.ID, Greater1.MinID FROM (SELECT post_title, MIN(ID) AS 'MinID', MAX(ID) AS 'MaxID' FROM ".$prefix."posts WHERE post_type = 'post' AND post_status = 'publish' 
    
            GROUP BY post_title HAVING COUNT(post_title)>1) AS Greater1 
    
            LEFT JOIN (SELECT post_title, ID FROM ".$prefix."posts) AS Titles 
    
            ON Greater1.post_title = Titles.post_title WHERE ID > MinID) AS b ON a.ID = b.ID WHERE a.ID = b.ID");
    
    }
    
    add_action('publish_post', 'superPostCleaner');