title: Wordpress - how do I know if a menu item has children?
body: <p>I'm developing a wordpress theme with nested submenus. I need to make the elements with no children visually different from the ones that have children. Right now I have this menu, but that could change:</p>
  
  <pre><code>A
    a1
    a2
  B
    b1
    b2
  C
  </code></pre>
  
  <p>As you can see, A and B have children. C doesn't - I need it to be different in the CSS level.</p>
  
  <p>Ideally, I would like to have a <code>has-children</code> class in A and B, but not in C.</p>
  
  <p>So far I've managed to create a "Menu Walker" PHP class that I can instantiate and pass to <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu" rel="noreferrer">wp_nav_menu</a> . Its constructor looks like this:</p>
  
  <pre><code>class My_Walker_Nav_Menu extends Walker_Nav_Menu {
    function start_el(&amp;$output, $item, $depth, $args) {
      ...
      if(??? $item has children???) {
        // I know what to do here
      }
    }
  }
  </code></pre>
  
  <p>So, how do I tell whether <code>$item</code> has children, or is a leaf?</p>
  
  <p>EDIT: this question was answered by someone called "keesiemeijer" in the Wordpress forums. I'm leaving this bounty expired just in case he wants to reclaim it. Otherwise, I'll be marking my own answer as valid.</p>