Skip to content

Instantly share code, notes, and snippets.

@chriswagoner
Created October 5, 2021 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriswagoner/ebc4406fea3484a45846af0fb89a206e to your computer and use it in GitHub Desktop.
Save chriswagoner/ebc4406fea3484a45846af0fb89a206e to your computer and use it in GitHub Desktop.
Get the child or sibling pages
function mysite_child_pages() {
global $post;
if ( is_page() && $post->post_parent )
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
else
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
if ( $childpages ) {
$string = '<div id="blog-page-main"><ul class="seconday-menu">' . $childpages . '</ul></div>';
}
return $string;
}
add_shortcode('show_childpages', 'mysite_child_pages');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment