Displaying Subpages of Parent only?!?!
-
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.
I’m not the big coder, i out 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()) { $image=$title.'.png'; }; if(!file_exists(TEMPLATEPATH.'/images/'.$image)) { $image=$title.'.png'; } echo '<img src="'.get_bloginfo('template_url').'/images/'.$image.'" alt="" />'; ?> <?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 } } ?> </div> <?php } ?>
- The topic ‘Displaying Subpages of Parent only?!?!’ is closed to new replies.