Reputation: 3
To get my requirement I used below code...
<div class="home_single_item_headline">
<?php query_posts('post_type=post&category_name=Browser&post_status=publish&posts_per_page=6&paged='. get_query_var('paged')); ?>
<a href="<?php bloginfo('url'); ?>/category/<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>">Browser</a>
</div>
<div class="home_single_item_column floatleft">
<?php get_template_part('post-loop')?>
</div>
but I get the category link randomly means other category link. What will be the proper solution?
Upvotes: 0
Views: 828
Reputation: 776
You should use get_category_link($category_id).
So in your case you would have:
<?php $category = get_the_category(); ?>
<a href="<?php echo get_category_link($category[0]->term_id); ?>">Browser</a>
Upvotes: 1