Opened 2 years ago
Last modified 2 weeks ago
#17652 new defect (bug)
get_term_link doesn't accept $term->term_id without explicit casting as numeric
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Taxonomy | Version: | 3.1.3 |
| Severity: | minor | Keywords: | |
| Cc: | jonathanwold, eddie.moya+wptrac@… |
Description
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 (5)
- 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
This is due to get_term() and get_term_by() not int'ing the fields when using a raw context. See http://core.trac.wordpress.org/ticket/17646#comment:5 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)
comment:3
jonathanwold — 14 months 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 (http://codex.wordpress.org/Function_Reference/get_term_link) 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?
comment:4
DrewAPicture — 14 months ago
- Version changed from 3.3.1 to 3.1.3
The version field is used to track when a bug was first reported.

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