get_term_link() always links to homepage
-
Hi,
I created a custom post type with category taxonomy support.
On my archive template i have a dropdown with all categories to filter the archive.
Every category is linked with get_term_link(). The function works but it goes to the homepage. I want to link to the same page.<?php $args = array( 'type' => 'download', 'child_of' => 0, 'parent' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'category', 'pad_counts' => FALSE ); $categories = get_categories( $args ); ?> <?php if ( count( $categories ) ) : ?> <div class="btn-group margin-bottom-40"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> Categorie <i class="fa fa-angle-down"></i> </button> <ul class="dropdown-menu" role="menu"> <?php foreach ( $categories as $category ) : ?> <li <?php if ($category->cat_ID == get_query_var( 'cat' )) : ?>class="active"<?php endif; ?>><a href="<?php echo get_term_link( $category ); ?>"><?php echo $category->name ?></a></li> <?php endforeach; ?> </ul> </div> <?php endif; ?>
The links are now:
?cat=1
?cat=2
?cat=3But it should be:
?page_id=5&cat=1
?page_id=5&cat=2
?page_id=5&cat=3How can i fix this?
- The topic ‘get_term_link() always links to homepage’ is closed to new replies.