[wp-trac] [WordPress Trac] #41813: get_terms is hiding taxonomies that are not empty

WordPress Trac noreply at wordpress.org
Mon Sep 11 13:52:47 UTC 2017


#41813: get_terms is hiding taxonomies that are not empty
------------------------------+------------------------------
 Reporter:  subrataemfluence  |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Taxonomy          |     Version:  4.8.1
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------------------
Changes (by subrataemfluence):

 * keywords:  reporter-feedback =>


Comment:

 @boonebgorges I have created this custom taxonomy and associated it with
 attachment (not a typical custom post type). Here is my code to register
 the custom taxonomy:



 {{{#!php
 <?php
 add_action( 'init' , 'emfl_create_media_content_taxonomy' );

 function emfl_create_media_content_taxonomy() {
     register_taxonomy_for_object_type( 'media_content_category',
 'attachment' );
 }

 add_action('init', 'emfl_media_content_taxonomy', 0);

 /* Creating Custom Taxonomy */
 function emfl_media_content_taxonomy() {
     $labels = array (
         'name' => _x('Media Content Categories', 'Media Content
 Categories'),
         'singular_name' => _x('Media Content Category', 'Media Content
 Category'),
         'search_items' => __('Search Media Content Categories'),
         'all_items' => __('All Media Content Categories'),
         'parent_item' => __('Parent Media Content Category'),
         'parent_item_colon' => __('Parent Media Content Category:'),
         'edit_item' => __('Edit Media Content Category'),
         'update_item' => __('Update Media Content Category'),
         'add_new_item' => __('Add New Media Content Category'),
         'new_item_name' => __('New Media Content Category Name'),
         'menu_name' => __('Content Category')
     );

     /* Registering taxonomy for "attachment" */
     register_taxonomy('media_content_category', array('attachment'), array
 (
         'hierarchical' => true,
         'labels' => $labels,
         'show_ui' => true,
         'show_admin_column' => true,
         'query_var' => true,
         'rewrite' => array('slug', 'content_category')
     ));
 }
 }}}



 Replying to [comment:1 boonebgorges]:
 > `hide_empty` checks against the `term_taxonomy_id.count` column. My
 guess is that the values in this column are '0' for the missing terms.
 It's possible that this is because you're missing some necessary logic for
 updating term counts. Can you share the code you're using to register your
 media_content_category taxonomy? Is it associated with a custom post type,
 or some other type of object? The `update_term_callback` param for
 `register_taxonomy()` might be where you start your debugging.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41813#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list