Title: php IF function question
Last modified: August 19, 2016

---

# php IF function question

 *  [fcarthy](https://wordpress.org/support/users/fcarthy/)
 * (@fcarthy)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-function-question/)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [fcarthy](https://wordpress.org/support/users/fcarthy/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/php-if-function-question/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
