I need to find out the number of times a term/tag or category is used in a post in WordPress. I wrote the below SQL query.
SELECT t.name , count(*)FROM wp_terms t JOIN wp_term_taxonomy tt ON tt.term_taxonomy_id = t.term_id JOIN wp_term_relationships tr ON tr.term_taxonomy_id = tt.term_taxonomy_id JOIN wp_posts p ON p.id=tr.object_id Where t.name='3d'
This gives me a count of '1011' I know this is wrong because I randomly checked the posts which I got and the term was not used. Please advice where I might be going wrong?