Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#24562 closed enhancement (duplicate)

get_the_terms is not zero indexed array

Reported by: leedo's profile leedo Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.5.1
Component: Taxonomy Keywords:
Focuses: Cc:

Description

The return value of get_the_terms only says it returns an array. To me, this implies that it is an array of terms, beginning at index 0. In fact, it is closer to an associative array, using the term's ID as the key. Some documentation to this effect would be very useful. Or returning a simple array.

Expected return value:

array(1) {
  [0]=>
  object(stdClass)#1032 (10) {
    ["term_id"]=>
    string(4) "1274"
    ["name"]=>
    string(10) "Staff Blog"
    ["slug"]=>
    string(5) "blogs"
    ["term_group"]=>
    string(1) "0"
    ["term_taxonomy_id"]=>
    string(4) "1284"
    ["taxonomy"]=>
    string(13) "ars_post_type"
    ["description"]=>
    string(0) ""
    ["parent"]=>
    string(1) "0"
    ["count"]=>
    string(2) "52"
    ["object_id"]=>
    string(6) "266909"
  }
}

Actual return value:

array(1) {
  [1274]=>
  object(stdClass)#1032 (10) {
    ["term_id"]=>
    string(4) "1274"
    ["name"]=>
    string(10) "Staff Blog"
    ["slug"]=>
    string(5) "blogs"
    ["term_group"]=>
    string(1) "0"
    ["term_taxonomy_id"]=>
    string(4) "1284"
    ["taxonomy"]=>
    string(13) "ars_post_type"
    ["description"]=>
    string(0) ""
    ["parent"]=>
    string(1) "0"
    ["count"]=>
    string(2) "52"
    ["object_id"]=>
    string(6) "266909"
  }
}

Change History (1)

#1 @SergeyBiryukov
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #21608.

Note: See TracTickets for help on using tickets.