0
votes

Is it possible to show subcategories of categories in Wordpress?

Let's say I have category A and B. In A I have A1, A2 and A3. In B B1 and B2. Now I would like to show the categories on the frontend... something like:

Category A:
- A1
- A2
- A3
Category B:
- B1
- B2

Is this possible in Wordpress in an easy way? If yes, how?

Thanks

4

4 Answers

2
votes

Yes it's possible, in your theme set the depth argument passed to nav_menu function.

http://codex.wordpress.org/Function_Reference/wp_nav_menu

1
votes

A simple search for 'subcategories' on wordpress.org plugin area returns lots of examples.

http://wordpress.org/extend/plugins/search.php?q=subcategories

0
votes

1) Showing Subcategories while you are on any category page:

<?php
if (is_category())
{
$cur_cat = get_query_var('cat');
    if ($cur_cat) 
    {
        $new_cats = wp_list_categories('echo=false&child_of=' . $cur_cat . '&depth=1&title_li=&&show_count=1&hide_empty=0');
        echo '<ul>' . $new_cats . '</ul>';
    }
}
?>

2) Show All top Categories:

<?php wp_list_categories('depth=1&title_li=&exclude=1&show_count=1&hide_empty=0'); ?> 

3) show All top Categories + Subcategories like Tree menu:

Use FoCal plugin. 

4) also, try this code :

http://wpworks.wordpress.com/2011/01/13/displaying-categories-and-subcategories-tree-on-wordpress/
0
votes

Show Categories and subcategories in Drop Down List In Woocommerece in Wordpress

   <option value=''>All</option>

get_results($sql); foreach ($allfilters as $singlefilter) {

    ?>
 <option value="<?php echo $singlefilter->slug;?>" "<?php if($singlefilter->slug == $singlefilter->name) echo 'selected'; ?>"> <?php echo $singlefilter->name;?></option>;

<?php }

?>