• Resolved baymediaarts

    (@baymediaarts)


    I am putting a new website up. I edited the sidebar so that each page show current page and all its children. for some reason this info is showing up under the content and the home link stays in the sidebar. take a look at the website and below is the code for sidebar. https://www.musicianstelevision.com

    <div class="sidebar">
    <?php wp_page_menu('show_home=1&include=9999'); ?>
    <!-- subnavigation (if children exist) -->
    <?php
    /* if the current pages has a parent, i.e. we are on a subpage */
    if ( $post->post_parent) {
    	$parent_title = get_the_title($post->post_parent);
    	$parent_link = get_permalink($post->post_parent);
    	$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0");
    // list the parent page
    	$children = wp_list_pages("depth=1&title_li=&child_of=".$post->post_parent."&echo=0");
    // append the list of children pages to the same
    }																							// $children variable
    
    /* else if the current page does not have a parent, i.e. this is a top level page */
    else {
    	$parent_title = get_the_title($post->ID);
    	$children = wp_list_pages("title_li=&include=".$post->ID."&echo=0");
    	$children = wp_list_pages("depth=1&title_li=&child_of=".$post->ID."&echo=0"); // form a list of the children of the current page
    }
    
    if ($children) {
    	echo "<div style='width: 220px; padding-top: 25px; height: 100%;'>";
    	echo "<a href='" . $parent_link . "'>" . $parent_title . "</a>";
    	echo "<ul style='list-style: none; padding-left: 20px;'>";
    	echo $children; /*print list of pages*/
    	echo "</ul>";
    	echo "</div>";
    } ?>
    </div>
    </div>

    Thanks,
    Holly

    ps. I used this code for another website and it worked fine.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘sidebar moving under the content’ is closed to new replies.