Skip to content

Instantly share code, notes, and snippets.

@mprahweb
Created July 8, 2016 06:52
Show Gist options
  • Save mprahweb/3c94d9c65b32ec9e3b2908305efd77d5 to your computer and use it in GitHub Desktop.
Save mprahweb/3c94d9c65b32ec9e3b2908305efd77d5 to your computer and use it in GitHub Desktop.
Divi 2.7.0 // Display a List of Child Pages For a Parent Page in WP
function wpb_list_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 = '<ul>' . $childpages . '</ul>';
}
echo $string;
}
add_shortcode('wpb_childpages', 'wpb_list_child_pages');
@mprahweb
Copy link
Author

mprahweb commented Jul 8, 2016

Shortcode: [wpb_childpages]
PHP-Template:

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