Display a list of sub-pages of Custom Post Type Parent Page

I am trying to display the sub-pages of a custom page on the parent page. I found an abbreviated code that works very well for standard WordPress post_type “pages”, but does not work for custom publishing types.

Here’s the short code code I put in my functions.php file:

function v_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(‘v_childpages’, ‘v_list_child_pages’);

If I place the shortcode[v_childpages] on a post_type “page” with children, it successfully displays all subpages in the linked list. But if I add it in a custom post_type, it’s not like that.

Any advice or suggestion is welcome, thank you!

Read more here:: Display a list of sub-pages of Custom Post Type Parent Page

Leave a Reply

Your email address will not be published. Required fields are marked *