#17652 closed defect (bug) (duplicate)
get_term_link doesn't accept $term->term_id without explicit casting as numeric
| Reported by: | tomauger | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Taxonomy | Version: | 3.1.3 |
| Severity: | minor | Keywords: | |
| Cc: | Focuses: |
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
@
15 years ago
- Summary get_term_link doesn't accept term_ID → get_term_link doesn't accept $term->term_id without explicit casting as numeric
#2
@
15 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
@
14 years ago
- Cc added
- Version 3.1.3 → 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?
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
get_term_link(intval($term->term_id), $term->taxonomy); ok