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

WordPress Trac wp-trac at lists.automattic.com
Wed Jul 25 17:12:19 UTC 2012


#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:  fixed
 Keywords:               |
-------------------------+---------------------
Changes (by nacin):

 * keywords:  2nd-opinion dev-feedback =>
 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 A post type is "post", "page", "book"

 A taxonomy is "tag", "category", "author"

 A term is "programming reference", "Non-Fiction", "Andrew Nacin"

 get_the_category() will work on a post and return Non-Fiction, which is a
 category assigned to that post. (To put it another way, it is a term in
 the taxonomy of category.)

 If you want to get the terms for a custom taxonomy for a post, don't use
 get_the_category(). Use get_the_terms(), specifying the taxonomy you'd
 like.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21378#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list