WordPress.org

Forums

PHP Custom Sidebar (1 post)

  1. JoeyJackson
    Member
    Posted 2 years ago #

    I am new to PHP and WordPress. I am attempting to create a new sidebar theme to display the third tier of the menu when on the second tier. Example:

    PAGE1
    -SUB1
    -SUB2
    --THIRD1
    --THIRD2
    -SUB3
    PAGE2
    PAGE3

    Currently when I am on PAGE1; SUB1, 2 and 3 appear in the sidebar. however when I am on SUB2 only SUB1, 2 and 3 show up instead of THIRD1 and 2. I am pretty sure this is the PHP file that is giving me the issue. (below) Any help or suggestions would be appreciated. Thanks -Joey

    <?php
    
    if(!$post->post_parent){
    
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1&exclude=-107");
    
    }else{
    
    if($post->ancestors)
    
    {
    
    $ancestors = end($post->ancestors);
    
    $children = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0&depth=1&exclude=-107");
    
    }
    
    }
    
    if ($children) { ?>
    
    <ul class="subnav">
    
    <?php echo $children; ?>
    
    </ul>
    
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags