Search for Orphaned Post Meta Data

Here is a SQL statement that allows you to search the database for orphaned post meta data. So it looks for any meta data that no longer has a corresponding post in the posts table. SELECT pm.meta_id, pm.post_id FROM wp_postmeta as pm LEFT JOIN wp_posts as p ON...

Clean Up Orphaned postmeta Data

Sometimes you run into a time where you need to go into the database and delete items from the posts table.  So after doing this you could have a lot of extra data getting stored in the postmeta table that is no longer needed.  This is a simple MySQL command that can...

Create CSV File using PHP

Came across this nice little bit of code to write a CSV file on the fly using PHP and grabbing the data from a MySQL database.  Thank you Stephen Morley for authoring a great little how to. // output headers so that the file is downloaded rather than displayed...

Manually Modifying WordPress’s URL via SQL

Sometimes it is easiest to modify the URL globally through SQL.  Here are the main commands you are going to want to run to modify the URL's throughout the database. UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldurl',...