Opened 14 years ago
Closed 14 years ago
#17449 closed defect (bug) (worksforme)
get_term_link does not work on dereived terms from get_category
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 3.1.2 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
I was noticing that get_categories as of 3.0 allows you to specify a taxonomy, which is great! because there's lots of useful args to be passed into get_categories, but there seems to be a problem where once you have a list of terms for a given taxonomy you can not use get_term_link to retrieve the link to your term.
sample:
Does NOT work
$args = array('taxonomy' => 'my_cool_tax' );
$terms = get_categories( $args );
Does WORK
$taxonomy = 'my_cool_tax';
$terms = get_terms( $taxonomy );
foreach( $terms as $term ) {
$html .= '<li><a href="'.get_term_link( $term->slug, $term->taxonomy ) . '"'>'.$term->name.'</a></li>';
}
print '<ul>' . $html . '</ul>';
Change History (1)
Note: See
TracTickets for help on using
tickets.
Both examples work for me on 3.2.1 and 3.3-trunk with standard and custom taxonomies.
Please reopen with more details if there's still a problem.