Support » Plugins and Hacks » figure out if this page has children?

  • Hi everyone,

    I’ve been fiddling around with wp_list_pages and have my own version written when does an easy expandable menu. I can distinguish between posts which have a depth of 0/1 and anything else, but what I haven’t been able to do is distinguish between a top-level page that has children and one that doesn’t.

    If a page has children, I want to use javascript to expand the menu and show the children — not link to the page. If it doesn’t have children, I want it to not do any javascript and link to the page. Here’s how I’ve got the top-level pages targeted so far:

    ($depth ==1 ) ? $output = call_user_func_array(array(&$this, 'iparent_start'), $cb_args) : $output = call_user_func_array(array(&$this, 'istart_el'), $cb_args) ;

    But of course pages with no children are still $depth = 1. So I need to find something else to say “if $depth=1 AND there are no children, call some other function”.

    Anyone know how I might start figuring out of a page has children or not?


  • The topic ‘figure out if this page has children?’ is closed to new replies.