Make WordPress Core

Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#17652 closed defect (bug) (duplicate)

get_term_link doesn't accept $term->term_id without explicit casting as numeric

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


global $wp_query;

$term = $wp_query->get_queried_object();

get_term_link($term, $term->taxonomy); ok

get_term_link($term->slug, $term->taxonomy); ok

get_term_link($term->term_id, $term->taxonomy); WP_Error ('Empty Term')

echo ($term->term_id); ok (echoes correct ID)

Change History (7)

#1 @tomauger
13 years ago

  • Summary changed from get_term_link doesn't accept term_ID to get_term_link doesn't accept $term->term_id without explicit casting as numeric

get_term_link(intval($term->term_id), $term->taxonomy); ok

#2 @dd32
13 years ago

This is due to get_term() and get_term_by() not int'ing the fields when using a raw context. See for a patch which sanitizes them.

See also #16469 (This and that can probably be closed as a duplicate of either #17646 or one of the other int'ing tickets)

#3 @jonathanwold
12 years ago

  • Cc jonathanwold added
  • Version changed from 3.1.3 to 3.3.1

I ran into this today trying to get the link using the term_id. The codex ( specifies that term_id can be used. Should I update it to reflect that there is a bug or just hold tight until the bug is fixed?

#4 @DrewAPicture
12 years ago

  • Version changed from 3.3.1 to 3.1.3

The version field is used to track when a bug was first reported.

#5 @eddiemoya
11 years ago

  • Cc eddie.moya+wptrac@… added

#6 @ericmann
11 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #17646.

#7 @dd32
11 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.