1. Home
  2. Snippets
  3. WP Tips

SQL Query to Get Posts Using Category Name

How2Buy // (Updated: )

select, 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 = 'Renewed'

Leave a Reply

Your email address will not be published. Required fields are marked *

Share Share Tweet