[wp-trac] [WordPress Trac] #14625: Function get_the_category doesn't work as expected with custom post types

WordPress Trac wp-trac at lists.automattic.com
Mon Aug 16 17:02:10 UTC 2010


#14625: Function get_the_category doesn't work as expected with custom post types
--------------------------+-------------------------------------------------
 Reporter:  bjdj          |       Owner:                    
     Type:  defect (bug)  |      Status:  new               
 Priority:  normal        |   Milestone:  Awaiting Review   
Component:  General       |     Version:  3.0.1             
 Severity:  minor         |    Keywords:  get_the_category()
--------------------------+-------------------------------------------------
 On a category page, the function 'get_the_category()' does not work as
 expected, combined with custom post types.

 If a category has no posts assigned to it, 'get_the_category()' will
 return an empty array (probably because the global $post variable is empty
 as well?). If your WordPress installation only uses custom post types
 (like mine), and never uses the post_type 'post', this could be a problem.

 I think I found an easy, not very beautiful, workaround for this problem;
 assign a post, which has post_type 'post', to all categories. That way,
 'get_the_category()' returns an array with information.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14625>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list