/ Published in: PHP
Use getTopParentPostName() to get the parent slug. Then use get_ID_by_slug() to get the ID of it. The use wp_list_pages() to display the child pages :)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // get parent ID function getTopParentPostName($myid) { $mypage = get_page($myid); if ($mypage->post_parent == 0) { return $mypage->post_name; } else { return getTopParentPostName($mypage->post_parent); } } // get ID of parent from slug function get_ID_by_slug($page_slug) { $page = get_page_by_path($page_slug); if ($page) { return $page->ID; } else { return null; } } 'echo' => 1, 'title_li' => '', 'child_of' => get_ID_by_slug(getTopParentPostName($post->ID)), 'sort_column' => 'menu_order, post_title'); ?> <?=wp_list_pages( $args );?>