Created
February 9, 2022 17:03
-
-
Save chriswagoner/caf1917d3ae29c1316973ee61b38cc36 to your computer and use it in GitHub Desktop.
Get Child Pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="child-page-main"><ul class="seconday-menu">' . $childpages . '</ul></div>'; | |
} | |
return $string; | |
} | |
add_shortcode('mysite_childpages', 'mysite_child_pages'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment