Revision: 13746
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at May 5, 2009 10:02 by jkriddle
                            
                            Initial Code
SELECT * FROM wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id
INNER JOIN wp_term_relationships wtr ON wtr.term_taxonomy_id=wtt.term_taxonomy_id
LEFT JOIN wp_posts wp ON wp.ID=wtr.object_id
WHERE
taxonomy='post_tag'
AND ID IS null
AND NOT EXISTS(SELECT * From wp_terms wt2
                INNER JOIN wp_term_taxonomy wtt2 ON wt2.term_id=wtt2.term_id WHERE wtt2.parent=wt.term_id)
ORDER BY name
                                Initial URL
Initial Description
If you run a query to delete old posts manually from MySQL in a WordPress database, the old tags will remain and appear in your tag cloud/listing. This allows you to identify those unused tags, and then delete them with an additional query.
Initial Title
WordPress Query to Identify Unused Tags
Initial Tags
wordpress
Initial Language
MySQL