Support » Plugins and Hacks » Hacks » count_user_posts_by_taxonomy

  • hi i know there is a fuction like count_user_posts_by_type and even a patch for it for post type, but is there anything for taxonomies? i really need to get tho authors per taxonomy. is there a query ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    Yes there is a query, but it gets rather complex, as several table joins are required. In plain english using SQL logic, you want a count of distinct users who are authors of posts associated with a particular taxonomy where the term is ‘whatever’. Unfortunately, my SQL skills prevent me from providing a workable query. Maybe someone else will be able to help you, but at least you know it’s possible.

    If that’s too mind boggling, you could use WP_Query to retrieve all posts associated with a taxonomy term, then use code to tally up the number of distinct authors. Very inefficient compared to SQL, but fairly easy to code. The only challenge is ensuring you are incrementing the counter only when a author hasn’t been counted yet.

    thanks bcworkz i know i can query all posts and then count em but i use another way, i’m developing a site with no post therefor i add my own hook to add count to user meta when user create a new post defined taxonomy, its way efficent and way better than any other solutions.

    anyway if someone able to add this query it will useful for future, maybe someone need it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘count_user_posts_by_taxonomy’ is closed to new replies.