WordPress.org

Ready to get started?Download WordPress

Forums

Check for grandchildren menu? (1 post)

  1. Kettercat
    Member
    Posted 1 year ago #

    [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; ?>
    </ul>
    <?php } else { ?>
    <?php } ?> 
    
    <ul id="grandnav">
    <?php
    $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 } ?>
    </ul>

    Thanks in advance!

Topic Closed

This topic has been closed to new replies.

About this Topic