[wp-trac] [WordPress Trac] #22471: get_category_parents problem with sub-categories (all WP Versions - to 3.5 beta)

WordPress Trac noreply at wordpress.org
Tue Jun 24 08:24:43 UTC 2014


#22471: get_category_parents problem with sub-categories (all WP Versions - to 3.5
beta)
--------------------------+-------------------------
 Reporter:  wpweaver      |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  General       |     Version:  1.2
 Severity:  normal        |  Resolution:  worksforme
 Keywords:  close         |     Focuses:
--------------------------+-------------------------
Changes (by mcleod@…):

 * status:  reopened => closed
 * resolution:   => worksforme


Comment:

 A second observation is that this might be related to get_the_category().
 This gives a list of categories, not necessarily in hierarchical order.
 Somewhere in the codex or elsewhere (need to research where that was), it
 is stated that the last child in the hierarchy is the first category
 returned from get_the_category(). This is not true.

 Example:
 $categories = get_the_category();
 $category = $categories[0];
 echo get_category_parents($category, ' - ');

 This gives unexpected results as described in this very ticket, if
 $category is not the last child in the hierarchical chain.

 If the $category argument is the last child, the results are as expected.
 So I was probably wrong to re-open this ticket and I will close it again
 until I have more results.

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


More information about the wp-trac mailing list