Skip to content

Instantly share code, notes, and snippets.

@bhubbard
Last active August 29, 2015 14:16
Show Gist options
  • Save bhubbard/188ab2ffa20ac53c69c4 to your computer and use it in GitHub Desktop.
Save bhubbard/188ab2ffa20ac53c69c4 to your computer and use it in GitHub Desktop.
Delete Tags from WordPress that have no posts -- http://www.makeuseof.com/tag/7-wordpress-database-queries-search-blog/
SELECT name, slug
FROM wp_terms
WHERE term_id
IN (
SELECT term_id
FROM wp_term_taxonomy
WHERE taxonomy='post_tag'
AND count='0'
);
DELETE FROM wp_terms
WHERE term_id
IN (
SELECT term_id
FROM wp_term_taxonomy
WHERE taxonomy='post_tag'
AND count='0'
);
SELECT ID, post_title
FROM wp_posts
WHERE post_status = 'publish'
AND post_author = 11;
SELECT ID, POST_TITLE
FROM wp_posts
WHERE post_content LIKE '%src=%'
AND post_status = 'publish'
LIMIT 100;
SELECT ID, POST_TITLE
FROM 'wp_posts'
WHERE 'post_type' = 'post'
AND 'post_date' > '2009-04-15 08:00:00'
AND 'post_date'< '2009-04-30 08:00:00'
LIMIT 100;
SELECT p.id as post_id, u.user_nicename as author, p.post_title, p.post_name as post_slug, p.post_date as local_publish_date, p.comment_count
FROM wp_posts p, wp_users u
WHERE p.post_status='publish'
AND p.post_type='post'
AND u.id = p.post_author
ORDER BY p.post_date DESC
LIMIT 500;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment