I am using this code to display subcategory in a category
<?php $this_category = get_category($cat);
$id = get_query_var('cat');
$args = array( 'parent' => $id );
$catdesc = $cat->category_description;
foreach (get_categories($args) as $cat)
:?>
<a href="<?php echo get_category_link($cat->term_id); ?>">
<?php echo ("$cat->cat_name"); ?></a>
<?php endforeach ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
get_template_part( 'content/content', get_post_format() );
?>
<?php endwhile; ?>
The problem is that all the posts in the category display under the category and the subcategory.
But i want to display posts under that subcategory only, not in category.
1 comment