Try this – I’ve not implemented it fully, but I have tested it and it seems to work. Place it in your functions.php and call <?php list_child_pages(); ?>
in your template or use the shortcode [childpages]
in your editor.
<?php
// List Child pages of a parent.
function 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 ) { ?>
<menu>
<ul class="side-nav">
<?php echo $string = $childpages; ?>
</ul>
</menu>
<?php
}
return $string;
}
// Add Shortcode for additional support, not just in the theme template
add_shortcode('childpages', 'list_child_pages');
?>
Related Posts:
- Add a submenu to wp_nav_menu
- Multi Level Bootstrap Navigation Menu in WordPress
- Custom Nav Walker sub-menu HTML construct
- Adding different classes to anchor in navigation menu
- how to automatically generate hierarchical menus from hierarchy of pages?
- How to display dynamic content in start_lvl function
- Menus like a CMS
- How to have custom menu Item CSS Classes for wp_page_menu() or wp_list_pages()
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- Check if menu id = $specific_id – then insert specific
- wp_nav_menu() with multiple Class
- Trying to Create Menu in WordPress
- How do I add recent posts to the menu?
- Automatically list top level menu item child pages
- Check if menu_item has children or has parent
- Change submenu markup
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- Adding toggle-able element after menu item
- How to Add support for sub-menu item description in wordpress?
- Add Different Class on Different Ul in twenty-twentyone theme
- Is it all right to put the whole tag into template_part file?
- wp_nav_menu container style args
- Bootstrap Theme Migrated to WordPress
- WordPress + Bootstrap: Replace primary navigation menu on mobile?
- How can I click the parent menu then redirect to a special URL?
- Creating navigation out of specific IDs and their children?
- Where to place a svg chevron down in my custom walker?
- Add href to tag in nav menu for mobile
- Conditional Nav Menu Inside Nav Menu Across Multisite Sites
- Show Child of Parent Page including all other parents
- nav_menu: how to force a subpage switching on the parent menu
- How was this menu system created?
- Display sub menus as separate lists
- Give custom class names to WP nav sub-menu
- Nav walker bootstrap: Display 3rd level and 4th level in dropdown menu
- wp_nav_menu parent in submenu
- How to add toggle-able DOM element after nav menu item?
- Display a portion/ branch of the menu tree using wp_nav_menu()
- Programmatically add a Navigation menu and menu items
- Dynamically exclude menu items from wp_nav_menu
- Split up wp_nav_menu with custom walker
- Is there an easy way to replace a custom menu link with a page or post?
- How to Add to Each Menu Link with link text to data-attr?
- Add Javascript to WordPress Menu
- Add custom menu item using wp_nav_menu_items filter
- Filter wp_nav_menu()
- How to modify navigation menu of the “My Account” page in WooCommerce
- Custom ID for certain menu item?
- how to create a menu with all sub categories?
- Add data-icon input to WordPress custom menu links
- Add separator to admin submenu
- Display only page specific sub menu items using Custom Walker
- How to get IDs for objects in menu branch?
- Show just one level of child pages, wp_list_pages woe
- How do I show a different secondary navigation menu for each section of my website?
- wp_nav_menu changed to wp_page_menu
- Add a navigation menu item using MySQL
- how to make a walker to this (in bootstrap, i try but not work)
- How to add or remove borders in navigation menu?
- How to make an anchored page in a navigation menu tab
- Should I custom code drop down menus or use a wordpress plugin?
- How can I alter the visible menu according to which level I am on [closed]
- How to display a submenu as a popup when clicking a button?
- Site pages show the page title under navigation bar
- how to mage the submenu open on wordpress active page
- Creating an accordion style menu
- nav tag wrapping around dropdown
- Site navigation sits unstyled for a second on page reload [closed]
- how can i get the page_ID in nav li [closed]
- How do i add logo in wordpress studiopress (glam theme)?
- Navigation menu, remove item from desktop
- Wrapping my ‘s with
- Custom navigation / menu output (walker?)
- How can I structure my pseudo footer nav code with wordpress codex code?
- Two Homes In Navigation Menu
- How to set menu Display location
- WordPress menu is getting automatically nested
- Add featured posts to nav menu
- What is the best way to incorporate responsive dropdown navigation menu into custom theme?
- WordPress “add to menu” button not working
- How to add a class directly on a unordered list element that is a primary navigation
- How do I programatically remove Menus?
- Navigation menu displays permalinks
- Displaying a Custom Avatar in WP Bootstrap Navwalker Menus in WordPress
- Add acf custom fields so sub item in menus
- Is there a way to make it so that I don’t get a hamburger menu, but rather a desktop style nav, when resizing to a mobile size
- Tried to hide navigation menu on one page ended up SCRAMBLING the navigation menu on another
- Render link description in navigation block
- Header not showing in new pages
- There is no option to click the button in header only on some pages
- Off-Canvas Menu Toggle Issue After WordPress Core Update
- Add a new menu selector element into WordPress nav-menus.php
- I only want to show links to categories that have posts in ‘publish’ state in my menu
- Can I create main menu without using built-in menu
- Remove WordPress Menu Classes and ID with Bootstrap Walker
- How to get and set post meta for core/navigation-link?
- Is there any documentation on JS trigger for the Gutenberg “Navigation” block?
- Primary menu item is not highlighting when page is active even though it is linked from a url with query string to pre-populate a form field
- How to get the navigation menu items? [closed]
- Change color of active link to navigation menu