[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 18:57:25 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:  reporter-feedback
--------------------------+-------------------------------------------------

Comment(by bjdj):

 On my category pages (http://example.com/?cat=X) I have the following
 block of code:

 <?php
         global $post;
         $gtc_test = get_the_category();
         print_r($gtc_test);
         print_r($post);
 ?>

 Both arrays are empty on category pages which have no posts with posttype
 'post' assigned e.g. if a category has posts with posttype 'movie' both
 arrays will stay empty.

 If a category does have a post with posttype 'post' both arrays will be
 filled with data and it is possible to retrieve the data e.g. the 'cat_ID'
 from the get_the_category() array.

 I hope this answers your question

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


More information about the wp-trac mailing list