I have this code:
<?php
// List subcategories of category '4'
$subcategories = get_categories('&child_of=4');
foreach ($subcategories as $subcategory) {
echo sprintf(' <a href="%s">%s</a> <span class="sep">•</span>', get_category_link($subcategory->term_id), apply_filters('get_term', $subcategory->name));
}
?>
This code retrieves a list of subcategories from category id 4. I have added this code in post loop(have_posts()
). It is showing all tagged subcategories from that category on every post's box.
What I want is to just show the subcategories from the category 4, which is tagged in that post. It shouldn't show all the subcategories from all categories tagged for all the posts.
Thanks in advance