Linked pages related to the current page. If is root page shows itself as title with all children below. Else shows immediate parent as title with all pages at its level below (depth can be changed, with -1 showing all without hierarchy).
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function jma_sidebar_addon() { global $post; 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'); } ?> <?php if ($children) { ?> <div class="maincontent"> <h3>More <?php echo get_the_title($post->post_parent);?></h3> <ul class="blog-list"> <?php echo $children;?> </ul> </div><?php } } add_action('themeblvd_sidebar_sidebar_right_before', 'jma_sidebar_addon'); |