Title: function category_has_children
Last modified: August 22, 2016

---

# function category_has_children

 *  [zecke](https://wordpress.org/support/users/zecke/)
 * (@zecke)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/theme-function-category_has_children/)
 * Hi
 * So I got the function that`s checking if the current category has any children.
   And it works great on archive.php template. But I want to do exact same thing
   on single.php but it doesn`t work… If You know what should I change in the code
   belowe to make it work also on single.php I would be delighted:
 *     ```
       function category_has_children() {
       global $wpdb;
       $term = get_queried_object();
       $category_children_check = $wpdb->get_results(" SELECT * FROM wp_term_taxonomy WHERE parent = '$term->term_id' ");
            if ($category_children_check) {
                 return true;
            } else {
                 return false;
            }
       }
       ```
   

The topic ‘function category_has_children’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [zecke](https://wordpress.org/support/users/zecke/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/theme-function-category_has_children/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
