Advertisement
Guest User

Untitled

a guest
May 16th, 2012
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. function published_term_count($term_id, $taxonomy){
  2. if($term_id && $taxonomy){
  3. global $wpdb;
  4. $query = "
  5. SELECT COUNT(ID) FROM $wpdb->posts
  6. LEFT JOIN $wpdb->term_relationships ON
  7. ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
  8. LEFT JOIN $wpdb->term_taxonomy ON
  9. ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
  10. WHERE $wpdb->posts.post_status = 'publish'
  11. AND $wpdb->posts.post_type IN ('post')
  12. AND $wpdb->term_taxonomy.taxonomy = '" . $taxonomy . "'
  13. AND $wpdb->term_taxonomy.term_id = '" . $term_id . "'
  14. ";
  15. }
  16. return $wpdb->get_var($query);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement