WordPress.org

Forums

Make Subcategory Dissappear (If None) (1 post)

  1. robmaguire
    Member
    Posted 8 years ago #

    On our site, whenever one is looking at a category page, WP lists the subcategories on the left hand side

    Example: http://citizen.nfb.ca/blogs/category/citizenshift/

    However, whenever the category does not have subcategories, the subcategory header is still listed.

    Example: http://citizen.nfb.ca/blogs/category/podcasts/

    How would I go about coding something that says to WP "If there are no subcategories for this category, do not show the subcategory header" ?

    Thanks!

    Here is the relevant code from the sidebar:

    <?php if ((is_category())||(is_single())) { ?>
    	<li>
    		<h2>Categories</h2>
    
    	<?php if($parent_category->cat_name == '') { ?>
    		<ul>
    		<?php wp_list_cats('child_of='.$this_category->cat_ID); ?>
    		</ul>
    
    		<?php } else { ?>
    		<ul>
    		<?php wp_list_cats('child_of='.$parent_category->cat_ID); ?>
    		</ul>
    		<?php } ?>
    	</li>

Topic Closed

This topic has been closed to new replies.

About this Topic