public
Last active

Child Page Menu Before Primary Sidebar Pagelines

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/**
* List child pages in content area
*/
 
function base_list_children() {
global $post;
$page_ID = $post->ID;
$ancestors = get_post_ancestors($page_ID);
$children = wp_list_pages("child_of=$page_ID&echo=0");
if( $children ) {
$parent = $post->ID;
} elseif ( $ancestors ) {
$parent = $post->post_parent;
}
if( isset($parent) ) {
$section = get_the_title($parent);
$childlist = wp_list_pages("title_li=&child_of=$parent&echo=0");
if( $childlist ): ?>
<div id="child-pages" class="widget">
<div class="widget-pad">
<div class="textwidget sub-nav">
<ul>
<h3><?php $permalink = get_permalink($post->post_parent); ?>
<a href="<?php echo $permalink; ?>"> <?php echo $section ?></a></h3>
<?php echo $childlist; ?>
</ul>
</div>
</div>
</div><!--// end #child-pages -->
<?php
endif;
}
}
add_action('pagelines_before_sb_primary','base_list_children');/* Change Pagelines Default Widget */

Add to child theme functions.php file

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.