dmccabe Posted July 16, 2008 Share Posted July 16, 2008 Firstly "please" dont ask me to ask this on the wordpress forums, their forums never seem to end in a useful answer if you get an answer at all. Every time I come to do anything with the Wordpress sidebar and displaying subpages, all hell brakes loose, when in fact what I am trying to do should be simple. Here is how the site works. In the header is the main navigation: About Us | Contracts | Portfolio When you click on one of these pages you get a submenu in the siderbar on the right, for example if you click on "Contracts" you see: - Completed -- Contract 1 -- Contract 2 -- Contract 3 -In Progress -- Contract 4 -- Contract 5 -- Contract 6 All good so far, if you click "Completed" or "In Progress" the menu again appaers as it is above, still good, however if you click on any of the individual contracts then you lose the rest of the options in the menu apart from those in that category, eg: if you click on "Contract 1" then the submenu only displays: -- Contract 1 -- Contract 2 -- Contract 3 I have gone through what must be hundreds of variations and combinations of was of displaying these pages, but nothing keeps the submenu's there at all times. It should be noted then when in the other main headings such as About Us or Portfolio, these all have their own submenu's that work, but the contracts page is the only one with sub pages of the pages if you get my meaning. Here is the code: </div> <!-- end of #content --> <div id="sidebar"> <ul> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?> <h2 style="width: 90%;">Sub-menu</h2> <ul> <?php echo $children; ?> </ul> <?php } ?> <!-- Freak --> <li id="sidebar-splitted"> <div class="splitted-left"> <h2 style="width: 90%;">Rouse News</h2> <ul class="splittedlists"> <?php wp_list_cats('sort_column=name&optioncount=0&hierarchical=1'); ?> </ul> </div> <div class="splitted-right"> <h2><?php _e('Archives'); ?></h2> <ul class="splittedlists"> <?php wp_get_archives('type=monthly&limit=12&show_post_count=0'); ?> </ul> </div> </li> <div class="searchbar"> <br /><?php include (TEMPLATEPATH . '/searchform.php'); ?> </div> <br /> <br /> <br /> <br /> <?php endif; ?> </ul> </div> <!-- end of #sidebar --> This is the important section of that code: <?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?> <h2 style="width: 90%;">Sub-menu</h2> <ul> <?php echo $children; ?> </ul> <?php } ?> with the wp_list_pages being the part that decides which pages to display. Also here is a reference to the wp_list_pages function that may help: http://codex.wordpress.org/wp_list_pages Genuine major thanks to anyone who can help me on this ??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.