Title: Hide subcategories (widget)
Last modified: September 1, 2016

---

# Hide subcategories (widget)

 *  [komani](https://wordpress.org/support/users/komani/)
 * (@komani)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/hide-subcategories-3/)
 * Greetings,
 * So I am working on making a widget, I have the option to hide categories from
   it. The list with options of what to hide consist of both categories and subcategories.
   Now, the problem is, if I tick a main category then all subcategories will automatically
   be shown also. Meaning nothing will be hidden. If I only tick subcategories without
   its parent, well then everything will be shown on the page as long as its parent
   is ticked. Any ideas on how I can enable hiding subcategories while showing its
   parent?
 *     ```
       <p>
       			<label for="<?php echo $this->get_field_id('nr_rows'); ?>"><?php _e('Only show cities below'); ?>:</label>
       			<?php echo '<input type="checkbox" name="'.$this->get_field_name('only_these').'"  value="1" '.(
       	 $instance['only_these'] == "1" ? ' checked="checked" ' : "" ).' /> '; ?>
       		</p>
   
               <p>
       			<label for="<?php echo $this->get_field_id('nr_rows'); ?>"><?php _e('Cities to show'); ?>:</label>
   
                       <div style=" width:220px;
           height:180px;
           background-color:#ffffff;
           overflow:auto;border:1px solid #ccc">
            <?php
   
       	 $terms = get_terms("ad_city","ad_city=0&hide_empty=0");
       	 foreach ( $terms as $term ) {
   
       	 echo '<input type="checkbox" name="'.$this->get_field_name('term_'.$term->term_id).'"  value="'.$term->term_id.'" '.(
       	 $instance['term_'.$term->term_id] == $term->term_id ? ' checked="checked" ' : "" ).' /> ';
       	 echo $term->name.'<br/>';
       ```
   
 * Any help would be much appreciated 🙂

Viewing 1 replies (of 1 total)

 *  Thread Starter [komani](https://wordpress.org/support/users/komani/)
 * (@komani)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/hide-subcategories-3/#post-7721508)
 * Bump

Viewing 1 replies (of 1 total)

The topic ‘Hide subcategories (widget)’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [komani](https://wordpress.org/support/users/komani/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/hide-subcategories-3/#post-7721508)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
