Simplest solution would be:
<li><ul>
<?php wp_list_pages('title_li=&child_of=".$post->ID."'); ?>
</ul></li>
Use this code for more flexibility:
<?php if ( is_page() ) { ?>
<?php
if($post->post_parent)
$children = wp_list_pages('title_li=&child_of=".$post->post_parent."&echo=0'); else
$children = wp_list_pages('title_li=&child_of=".$post->ID."&echo=0');
if ($children) { ?>
<li>
<h2>
<?php
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
?>
</h2>
<ul>
<?php echo $children; ?>
</ul>
</li>
<?php } } ?>
Related Posts:
- A check for if is parent page, if has children, if has grandchildren
- Can I display submenus in groups, using wp_list_pages?
- Only allow new subpages to be created
- WordPress twenty eleven sidebar on Pages
- Different “Text Widgets” in Sidebar on Many Different Pages?
- Registering multiple sidebars with data from an array
- Get Order of Meta Box in a Page/Post
- Create subpage – filter parent pages list
- How can I automatically add child pages to pages in a WP menu?
- how to display sidebar on pages in wordpress
- Keep page hierarchy in wp_list_pages, even if on a child or grandchild
- Displaying direct children of other pages on homepage
- creating single page with 2 columns while theme is 3 column
- Get all children titles of a page as a link to them
- Multiple Loops That Pull Pages (Child/Grandchild) While Styling the First Entry
- Search anything from a Child and Sub-Pages of their Parent page
- Show children connected to parent pages
- How to add custom php file to right sidebar?
- If page or sub page not working as expected
- Check if sidebar is active on page with id
- How to exclude sidebar from pages?
- 1st Level Page with No Children
- Page specific values in widgets
- How can I use Page editor for two separate templates?
- How to set post slug when using wp_insert_post();?
- Check if is on child-page of a particular page
- Restrict admin access to certain pages for certain users
- Require title for pages
- How to embed page content in a blog post
- How do I modify this page template to show subpage excerpts (not post excerpts)?
- What are the options for running custom css and javascript files on a page?
- How to build a post and comment editing form in a page?
- Wrong Sub-Page Order
- WP won’t save changes in post (any)
- can i create 2 blog ‘feeds’ within one blog
- Password Protected Page Not Displaying Content After Entering Password
- Created pages not showing up in ‘All Pages’ list
- I made a custom page but WordPress seems to strip any HTML I put in this page
- How to exclude shortcode from specific page IDs if it’s set to global
- WASM page in WordPress website
- Include a specific page in your template
- Is it possible to have a landing page based on the visitors location?
- Play Video on Homepage Only
- Extra title output with this function wp_list_pages
- Remove number in URL
- Dynamically change page that loads
- Page title not showing up
- How to add Posts to a Page
- Proper way to implement/access a built-in page in my theme
- remove/hide pages from users backend
- Page not found error when adding text `2 = 2 ^ 1` to the page
- Related Links Page with moderated, user suggested link submissions
- If a page does not exist, include a different page?
- How to redirect a page to another?
- Adding Author and Updated Schema Markup to WordPress Static Pages
- Get the ‘Content Permission’ roles as defined in a page
- Pages are hashed as of today
- Dynamic Landing Page
- Creating a dashboard menu page similar to the “Pages” page
- What is a subpage in WordPress?
- Get $post Object from another page
- Google Page Speed Insights not recognising WP-Cofig settings?
- Can I schedule my site to launch at a set time and date?
- Avoid pages losing template association on site re-deploy
- get_permalink not fetching correct pages
- Using page-something.php as static front page
- Query pages based on tags
- How do I centre all page titles site wide without centring post titles or site title?
- create 2 custom columns in page edit in Admin panel
- Having a series of pages created based on records in a table with fields populating the pages
- Authors posts on a author created page
- Check if page has subpages
- How should I set up a Tumblr blog at a WordPress Page?
- Hide links to pages that dont have any content
- custom page templating in WordPress
- WordPress – Retrieve a Page if it’s a direct descendant of another Page
- After creating a new page, filling the page with structure
- Page Slug Won’t Change – Can’t Edit Archive Page With Slug or Reassign Slug
- Create many pages with dynamic content based on 1 template
- wp_list_pages get the hole hierarchy for current page
- My English homepage will not update
- Display different pages based on form entry
- Single Sidebar; multiple templates! How?
- when clicking update after page editing it returns this page not working in wordpress
- WordPress comments section on pages not appearing
- Pagination For Page Post Type
- Edit Page Content not showing
- Managing many pages on a WordPress website
- How to get sort content by page id?
- custom page or standalone page?
- Avada Theme – Display results from a specific category [closed]
- Is it possible to rewrite a page url Without setting the permalinks to Post Name?
- Search page different title per results
- Approve Page Edits
- link a custom page into menu
- Show different number of posts on second page of category
- Use get_posts() with ‘post’ and ‘page’ queries at the same time?
- appearance of new page
- How can a user login on a wordpress page?
- For some reason my posts are not showing up on my front page [closed]