[wp-trac] [WordPress Trac] #38280: Make term count for a specific object type available

WordPress Trac noreply at wordpress.org
Mon Oct 10 21:54:24 UTC 2016


#38280: Make term count for a specific object type available
-------------------------+-----------------------------
 Reporter:  desrosj      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Taxonomy     |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Term count is the total number of relationships with no context of the
 object types the relationships belong to.

 Currently, the best way to determine the count of a term for a specific
 object type is to run a `WP_Query` with a `WP_Tax_Query` for that term.

 {{{#!php
 $term_count_query = new WP_Query( array(
         'post_type' => 'some-post-type',
         'tax_query' => array(
                 array(
                         'taxonomy' => 'some-taxonomy',
                         'field' => 'slug',
                         'terms' => array( 'term-slug' )
                 ),
         ),
         'posts_per_page' => 1,
 ) );
 $term_count_for_post_type = $term_count_query->found_posts;
 }}}
 Now that term meta is in core, it would be great if these counts were
 stored in term meta for easy access.

 To start, these counts could be available through a function. To go a step
 further, an argument could be added to `get_terms()` and other functions
 to filter the term counts and reflect the object types terms are being
 grabbed for.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38280>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list