0

I need to display child pages on my parent pages. i have a code that is working but i need to set some codes to only show specific pages like to only show visibility public not all the pages.

this is the code for the function.php to display the child pages on my parent page.

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');

shortcode

[wpb_childpages]
1

you can use post_status.

post_status
A comma-separated list of post status types that should be included. For example, 'publish,private'.

possible values are: (publish|inherit|pending|private|future|draft|trash)

or you can also play with:

include
Only include certain Pages in the list generated by wp_list_pages. This parameter takes a comma-separated list of Page IDs.

more about it here.. http://codex.wordpress.org/Function_Reference/wp_list_pages

| improve this answer | |
  • where do i put that on my code sir? i dont know about php – MIke Jan 21 '15 at 2:31
  • put inside wp_list_pages. sample: wp_list_pages( 'sort_column=menu_order&post_status=private,publish&include=133,441&title_li=&child_... – Reigel Jan 21 '15 at 2:41
  • please read the link given... – Reigel Jan 21 '15 at 2:43
  • i added it on the echo not on the sort column because it display the pages if i add the post status. also the publish is not working it also displays the private. i need to display the public pages only but there is no coded for visibility. – MIke Jan 21 '15 at 2:50
  • no worries i think i figure it out myself thanks for the help though – MIke Jan 21 '15 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.