Skip to content

Instantly share code, notes, and snippets.

@metinsaylan
Created December 21, 2023 22:55
Show Gist options
  • Save metinsaylan/60180a05bfc0e2ad8d8f39cb06b70dc4 to your computer and use it in GitHub Desktop.
Save metinsaylan/60180a05bfc0e2ad8d8f39cb06b70dc4 to your computer and use it in GitHub Desktop.
SQL Query to Get WordPress Posts Using Category Name
-- SQL Query to Get WordPress Posts Using Category Name
select p.id, p.post_title from wp_posts p
inner join wp_term_relationships tr on tr.object_id = p.ID
inner join wp_terms t on tr.term_taxonomy_id = t.term_id
inner join wp_term_taxonomy tt on tt.term_taxonomy_id = t.term_id
where post_status ='publish'
and tt.taxonomy = 'category'
and t.name = 'Featured'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment