I am trying to figure out how can I show subcategories for selected parent category in search.php. I have code which shows subcategories of all categories, but how can I modify this code to show subcategories for only selected category?
this is my code:
<?php while(osc_has_categories()) { ?>
<?php if(osc_count_subcategories() > 0) { ?>
<ul>
<?php while(osc_has_subcategories()) { ?>
<li>
<strong><a href="<?php echo osc_search_category_url() ?>"><?php echo osc_category_name(); ?></a></strong></label>
</li>
<?php } ?>
</ul>
<?php } ?>
<?php } ?>
thank you
When in a loop while(osc_has_categories())
, it allows you to use osc_category_*
helpers.
You could do something like:
<?php while(osc_has_categories()) { ?>
<?php if(osc_category_id() === 98): ?>
<?php if(osc_count_subcategories() > 0) { ?>
<ul>
<?php while(osc_has_subcategories()) { ?>
<li>
<strong><a href="<?php echo osc_search_category_url() ?>"><?php echo osc_category_name(); ?></a></strong>
</li>
<?php } ?>
</ul>
<?php } ?>
<?php endif; ?>
<?php } ?>