Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#18270 closed defect (bug) (invalid)

get_cat_ID() returns term_id rather than term_taxonomy_id

Reported by: georgestephanis's profile GeorgeStephanis Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:

Description (last modified by scribu)

get_cat_ID() currently returns the wrong value for a category id. It's giving the term id rather than the term taxonomy id.

As the category ID is the term_taxonomy_id -- I believe that this is just legacy code from before the term_id and term_taxonomy_id were separated.

However, if your site is not running a straight 1:1 ratio for term_id = term_taxonomy_id (as some aren't) it will not give you the correct category id.


have it return ->term_taxonomy_id; instead of ->term_id;


Change History (4)

#1 @scribu
13 years ago

  • Keywords reporter-feedback added

Erm, get_the_ID() only returns a post id.

Did you mean get_queried_object_id()?

#2 @GeorgeStephanis
13 years ago

  • Summary changed from get_the_ID() returns term_id rather than term_taxonomy_id to get_cat_ID() returns term_id rather than term_taxonomy_id

Gah, I'm an idiot. I meant get_cat_ID(). Editing the ticket now.

#3 @scribu
13 years ago

  • Description modified (diff)
  • Keywords reporter-feedback removed

#4 @scribu
13 years ago

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

All the taxonomy functions work with term_id, rather than term_taxonomy_id, even if it would have been nice if it did.

Unfortunately, we can't go about changing what get_cat_ID() returns, because it would break existing code that correctly expects it to return a term id.

Note: See TracTickets for help on using tickets.