Skip to content

Instantly share code, notes, and snippets.

@loorlab
Created December 22, 2024 05:39
Show Gist options
  • Save loorlab/0452f03123808e21db40ce2539dfbdf7 to your computer and use it in GitHub Desktop.
Save loorlab/0452f03123808e21db40ce2539dfbdf7 to your computer and use it in GitHub Desktop.
Query - MySQL - WordPress | Total Posts by No Category
SELECT p.ID, p.post_title, p.post_date
FROM wp_posts p
LEFT JOIN wp_term_relationships tr ON p.ID = tr.object_id
LEFT JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = 'category'
WHERE p.post_type = 'post'
AND p.post_status = 'publish'
AND tt.term_taxonomy_id IS NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment