This code spits out a list of categories, however I only need to show child categories of the current category being viewed. Any ideas?
<ul class="categoryNav">
<?php
$args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'exclude' => '',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( '' ),
'show_option_none' => __( '' ),
'number' => null,
'echo' => 1,
'depth' => 1,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'product_cat',
'walker' => null
);
wp_list_categories( $args );
?>
</ul>
I found the following seems to work:
I hope others find this helpful :] This method doesn’t seem to be documented anywhere else as far as I’m aware. It’s perfect for category navigation.
You have the
child_of
query parameter set to0
. Set it to the category currently viewed. Like: