Skip to content

Instantly share code, notes, and snippets.

@ellenmva
Created November 6, 2012 21:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ellenmva/4027846 to your computer and use it in GitHub Desktop.
Save ellenmva/4027846 to your computer and use it in GitHub Desktop.
Child Page Menu Before Primary Sidebar Pagelines
/**
* 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 */
@ellenmva
Copy link
Author

ellenmva commented Nov 6, 2012

Add to child theme functions.php file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment