Helpful SQL queries to run in WordPress

Here are a list of great queries to run on your WordPress installation.

Remove all spam comments from the database

DELETE FROM HYv3g_comments WHERE HYv3g_comments.comment_approved = 'spam';

Globally enable comments for all users

UPDATE HYv3g_posts SET comment_status = 'open';

Globally disable comments for all users

UPDATE HYv3g_posts SET comment_status = 'closed';

Globally enable comments for registered users only

UPDATE HYv3g_posts SET comment_status = 'registered_only';

Globally enable/disable comments before a certain date

UPDATE HYv3g_posts SET comment_status = 'closed' WHERE post_date < '2008-01-01' AND post_status = 'publish';

Globally enable pingbacks/trackbacks for all users

UPDATE HYv3g_posts SET ping_status = 'open';

Globally disable pingbacks/trackbacks for all users

UPDATE HYv3g_posts SET ping_status = 'closed';

Globally enable/disable pingbacks/trackbacks before a certain date

UPDATE HYv3g_posts SET ping_status = 'closed' WHERE post_date < '2008-01-01' AND post_status = 'publish';

Globally enable/disable all discussion: comments, pingbacks and trackbacks

UPDATE HYv3g_posts SET comment_status = 'open', ping_status = 'open' WHERE comment_status = 'closed' AND post_status = 'publish';

Globally enable/disable comments, pingbacks and trackbacks before a certain date

UPDATE HYv3g_posts SET comment_status = 'closed', ping_status = 'closed' WHERE post_date < '2008-01-01' AND post_status = 'publish';

Published by

Ryan Kessen

Computer Repair, Freelancer, Blogger, Reviewer and all around nice guy!