Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
<?php 
$categories=get_categories('taxonomy=galeriak'); 
foreach ($categories as $category) {
?>
    <li><a href="<?php echo get_category_link( $category->term_id ) ?>" title="<?php echo $category->name ?>"><?php the_term_thumbnail (  $category->term_id, $category->taxonomy, $size = 'thumbnail', $attr = '') ?><span><?php echo $category->name ?></span></a></li>
<?php } ?>

I use this code to display the categories from the "galeriak" taxonomy. Everything is working, except the href part, its return nothing. I tried it with and without the echo, but nothing seems to work. Any ideas?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You should be using get_term_link instead, also for consistencys sake and to future proof, use get_terms instead of get_categories. Both work on categories/tags and all custom taxonomies.

Also check for the return of a WP_Error object ( returned when an invalid or nonexistent term is passed )

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.