[wp-trac] [WordPress Trac] #21608: get_the_terms() returns an array with keys that are not starting from 0
WordPress Trac
wp-trac at lists.automattic.com
Thu Aug 16 13:54:35 UTC 2012
#21608: get_the_terms() returns an array with keys that are not starting from 0
--------------------------+-----------------------------
Reporter: boryanka | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.4.1
Severity: normal | Keywords:
--------------------------+-----------------------------
This is easy to reproduce. You need a custom post type (in my case
'events') and a custom taxonomy (in my case 'eventtype').
When I try to retrieve the names of the eventtypes associated with the
current event it gives back an array. The issue is that the key of each
array line is the ID of the term. Instead of starting from 0.
The code:
{{{
$terms = get_the_terms( $post->ID, 'eventtype' );
}}}
The output:
{{{
array(1) {
[6]=>
object(stdClass)#249 (10) {
["term_id"]=>
string(1) "6"
["name"]=>
string(5) "Event"
["slug"]=>
string(5) "event"
["term_group"]=>
string(1) "0"
["term_taxonomy_id"]=>
string(1) "6"
["taxonomy"]=>
string(9) "eventtype"
["description"]=>
string(0) ""
["parent"]=>
string(1) "0"
["count"]=>
string(1) "1"
["object_id"]=>
string(3) "182"
}
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21608>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list