#17652 closed defect (bug) (duplicate)
get_term_link doesn't accept $term->term_id without explicit casting as numeric
Reported by: | tomauger | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 3.1.3 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
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 (7)
#1
@
14 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
#2
@
14 years ago
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)
#3
@
13 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 (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?
#4
@
13 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.
get_term_link(intval($term->term_id), $term->taxonomy); ok