[wp-trac] [WordPress Trac] #21378: get_the_category doesn't work for custom post types with custom taxonomies

WordPress Trac noreply at wordpress.org
Thu Oct 27 22:58:21 UTC 2016


#21378: get_the_category doesn't work for custom post types with custom taxonomies
-------------------------+----------------------
 Reporter:  tcattitude   |       Owner:
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:
Component:  Taxonomy     |     Version:  3.4.1
 Severity:  normal       |  Resolution:  invalid
 Keywords:               |     Focuses:
-------------------------+----------------------

Comment (by slyvershyne):

 Tcattitude dude you are a genius !! And a life saviour.
 Thank you very much for all this !!!!   :)


 Replying to [comment:3 tcattitude]:
 > Maybe i just post this as an enhancement instead.
 >
 > I talking about this:
 > http://wordpress.org/support/topic/get-the-category-not-working-for-
 custom-post-type?replies=5#post-3013294
 >
 > {{{
 > function get_the_category_bytax( $id = false, $tcat = 'category' ) {
 >     $categories = get_the_terms( $id, $tcat );
 >     if ( ! $categories )
 >         $categories = array();
 >
 >     $categories = array_values( $categories );
 >
 >     foreach ( array_keys( $categories ) as $key ) {
 >         _make_cat_compat( $categories[$key] );
 >     }
 >
 >     // Filter name is plural because we return alot of categories
 (possibly more than #13237) not just one
 >     return apply_filters( 'get_the_categories', $categories );
 > }
 > }}}
 >
 > But for the default "get_the_category".
 >
 > Hope this can be reconsidered.

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


More information about the wp-trac mailing list