WordPress Add Child Pages

To arrange your wordpress pages in hierarchical  order insert this code.

Displaying Child Pages on the Parent Page in WordPress

To list child pages under a parent page, you need to add the following code in a site-specific plugin, or in your theme’s functions.php file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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>';
}
return $string;
}
add_shortcode('wpb_childpages', 'wpb_list_child_pages');

To display child pages simply add the following shortcode in a page or text widget in the sidebar:

 

Use the plugin Code Snippets

 

The above information comes from this page.

 

 

Some people you know may be interested in this information. Please Share It.

And you may want to return to this information. So bookmark or add it to your favorites now so you can easily find it again. Just press keyboard keys CTRL and D at the same time. Its that easy.

And so that you can easily find this page again, bookmark or add it to your favorites now.