• I have not found an easy way to check a category to see if it has children or not. Anyone have any ideas?

Viewing 1 replies (of 1 total)
  • This checks if Category 2 has children. Actually it checks the “wp_categories” table to see if any category has Category 2 for a parent.

    
    <?php $haveparent = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE category_parent = 2", ARRAY_N);
      if (is_array($haveparent)) {
         echo 'I am a parent'; }
    ?>
    
Viewing 1 replies (of 1 total)
  • The topic ‘Check cat for children’ is closed to new replies.