MrBonsai Posted December 15, 2011 Share Posted December 15, 2011 Hi Ppl, i got a problem, i just can't get it working.... I have a sidebar which only appears if the page has subpages and it lists only direct ones. So if I would have page1,page2,page3 with page3 only having subpages called subpage3a, subpage3b it seems working fine. But with the code below I have 2 problems. Problem 1: When clicked on a subpage the sidebar dissapears....that should not happen. Problem 2: If I add Subpages to subpage3a f.e. then the menu stays the same and it does not display the childs of subpage3a, if I click on subpage3 I'm not a great coder, i put this together with snippets of code. So I hope someone could help me! <?php $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0&depth=1'); if ($children) { ?> <div class="sidebarwrap"> <?php $title = get_the_title($post); $parent_title = get_the_title($post->post_parent); if(is_page()) { $check=$title.'.png'; }; if(file_exists(TEMPLATEPATH.'/images/'.$check)) { $image=$check; }; echo '<img src="'.get_bloginfo('template_url').'/images/'.$image.'" alt="" />'; ?> <ul> <?php if ( is_page() ) { ?> <?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=0&depth=1'); if ($children) { ?> <?php echo $children; ?> <?php } } ?> </ul> </div> <?php } ?> 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.