• I have a bit of php listing a submenu if the current category has children. However, it does not list this submenu if a submenu item is clicked.

    This is what I’ve got:

    <ul id="menu" class="clearfloat">
    	<li><a href="<?php echo get_option('home'); ?>/" class="on">Home</a></li>
     	<?php wp_list_categories('orderby=name&exlude=181&title_li=');
     	$this_category = get_category($cat);
     	if (get_category_children($this_category->cat_ID) != "") {
     		echo "<ul>";
     		echo "</ul>";
     	}
    	?>
    </ul>
    
    <ul id="submenu">
     	<?php if (get_category_children($this_category->cat_ID) != "") { ;?>
    	<?php wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID); };?>
    </ul>

    So when a main category item is clicked, I’m taken to that category and all of its children are listed. However, if I click on a child category, once I arrive there are no children listed… obviously, since I don’t have children of children categories.

    So how could I modify this IF statement at the end to also show me the children categories if indeed I’m at a page that is a child category?

  • The topic ‘php IF function question’ is closed to new replies.