I’ve got a template looping through each of the sub-categories in the main category you’ve selected. The title of each I would like hyperlinked, so if you select a sub-category you can now go to that specific categories posts.
However when using <?php get_category_link( $category_id ); ?>
, it outputs the permalink of the parent category instead.
<div class="row">
<?php $i = 1; $categories = get_categories("child_of=$cat"); foreach ($categories as $cat) { ?>
<div class="col-md-6">
<?php query_posts("cat=$cat->cat_ID&posts_per_page=1&order=ASC&orderby=name"); ?>
<div class="top-category-container">
<div class="category-label">
<span>Latest From</span>
<h2><a href="#"><?php single_cat_title(); ?></a></h2>
</div>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<div class="article-img">
<a href="<?php the_permalink(); ?>"><?php echo the_post_thumbnail('', array('class' => 'img-responsive')); ?></a>
</div>
<p><?php the_excerpt(); ?></p>
</div>
<?php endwhile; ?>
</div>
</div>
<?php } ?>
</div>
Change
to