Sidebar display categories if in category
-
I have the following code in my sidebar.php
<?php if (in_category('suction-cup-sizes')) : ?> <div id="cats-list-nav"> <ul> <?php wp_list_categories('orderby=title&hide_empty=0&use_desc_for_title=0&child_of=15&title_li='); ?> </ul> </div> <?php endif; ?> <?php if (in_category('suction-cup-types')) : ?> <div id="cats-list-nav"> <ul> <?php wp_list_categories('orderby=title&hide_empty=0&use_desc_for_title=0&child_of=6&title_li='); ?> </ul> </div> <?php endif; ?>
In my navigation I have 2 links to 2 categories. The category names are:
Suction Cup Sizes
Suction Cup TypesSo a post(product) lives in both categories. For example a Mushroom Head Suction Cup comes in 5 different sizes (micro, small, medium, large, giant). As do many of the other posts in the site.
Ok, enough of the background information. What I am trying to do is have the categories listed in the sidebar. Right now if a post is in both a sub category of “Suction Cup Sizes” and a sub category of “Suction Cup Types”- both navigation ul/li’s show up in the sidebar.
I need it so that when someone is at the URL of http://suctioncups.marketing-pittsburgh.com/category/suction-cup-sizes/ that the sidebar navigation only list subcategories of “Suction Cup Sizes”
The same goes for if a person is at http://suctioncups.marketing-pittsburgh.com/category/suction-cup-types/ that the sub category list of “Suction Cup Sizes” is not show.
- The topic ‘Sidebar display categories if in category’ is closed to new replies.