• Hi

    So I got the function thats 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 doesnt 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.