I have following format of subpages in wordpress:

About Us 
  -Services 
  -Products 
  -Surgery 

I want to list all subpages with parent page like above but the code that I am using

from wpbeginner site is not working as my requirement. Can somebody tell me that

how to show subpages with parent page.

I tried follwoing code in functions.php file:

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

And then use short code [wpb_childpages] in widget but it is showing only
child page but I want child page with parent page

Read more here: How to display list of child pages with parent in wordpress?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: