Support » Themes and Templates » Check for grandchildren menu?

  • [Duplicated threads will be deleted]

    Hey everyone,

    What am I missing? I created a menu of grandchildren pages, and I want it to appear only if the section has grandchildren pages, of course.

    There’s something wrong with the code obviously – as it also shows up when there are only children pages too.

    This is the code for both the children menu & the grandchildren menu:

    <?php if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1"); else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0depth=1");  
    if ($children && is_page()) { ?>
    <ul id="subnav">
    <?php echo $children; ?>
    <?php } else { ?>
    <?php } ?> 
    <ul id="grandnav">
    $grandchildren = wp_list_pages("title_li=&child_of=&child_of=".$post->ID."&echo=0depth=2");
    if ($grandchildren && is_page()) { ?>
    <?php echo $grandchildren; ?>
    <?php } else { ?>
    <?php } ?>

    Thanks in advance!

  • The topic ‘Check for grandchildren menu?’ is closed to new replies.