You can get top levels page id with following function
function find_top_level_id( $post_id ) {
$ancestors = get_post_ancestors( $post_id );
if ( $ancestors ) {
return end( $ancestors );
} else {
return $post_id;
}
}
You can use the returned value with wp_list_pages()
Related Posts:
- Show just one level of child pages, wp_list_pages woe
- Ways to give a wp_list_pages menu link specific class names?
- wp_list_pages – show pages immediately 1 level below current level
- Handling complex multi-level architecture / menu for large site
- No link on empty page in wp_list_pages
- wp_list_pages sort order is different for different languages [closed]
- wp_list_pages: only show subpages on the parent page?
- How to have custom menu Item CSS Classes for wp_page_menu() or wp_list_pages()
- Highlight another nav item
- wp_list_pages() but only show children on the branch you are on
- Displaying different page links on different pages
- How to remove the HOME menu item
- Dynamic menu wp_list_pages displaying only current branch including: current page, his siblings and its childs
- wp_list_pages Hierarchical Help
- Wp_list_pages not showing children with custom page template
- How to use wp_list_pages on a grandparent page
- Can you exclude child pages of a specific parent within a navigation?
- horizontal menu / 4-level depth
- Creating navigation out of specific IDs and their children?
- How to display list of child pages with parent in wordpress?
- wp_list_pages, links only for pages with no children
- Display all submenus
- Showing Custom Menus in the sidebar
- Second tier sidebar navigation
- Making current_page_item work with wp_list_pages in sidebar on post pages
- Display a portion/ branch of the menu tree using wp_nav_menu()
- Display only page specific sub menu items using Custom Walker
- non-clickable placeholder in the menu
- How to Move the Author Metabox into the “Publish” metabox?
- I want remove last after wp_nav_menu
- Add log in link to menu in Twenty Twelve
- Add within the output of
- Where to update the Static Pages Blacklist for Multisite Install?
- How to create a category menu?
- Vertical Sidebar Menu Parent and Child not displaying correctly [closed]
- Hide Menu items base on capability
- How to show Home Page link in WordPress Menu and how to add an icon to this?
- Remove li from wp_nav_menu
- Outside the loop, how can I echo the current page’s menu title?
- How do you return a menu with the menu name?
- do_action appearing outside of menu?
- two menus show different menu based on what menuitem is selected on menu1
- Appending a GET-Variable to wp_nav_menu
- You do not have permission to create Navigation Menus – Twenty Twenty-Two theme
- Walker class conditional based on parent menu item label or custom css class
- ‘wp_get_nav_menu_items’, when fired inside of the ‘wp_update_nav_menu’ hook, returns old menu items, instead of new
- Menu custom link not working for external site
- How to override the theme home page?
- custom walker class
- Sticky Header in WordPress using BootstrapWP theme [closed]
- Walker Class – Check if menu item has description and if so add class to li
- Multiple languages menus problem
- register_nav_menus, then create menus programatically
- How can I switch pages?
- How to override menu markup?
- How to remove dropdown from wp_nav_menu
- How can template identify what page it’s being used on?
- Automatically Display Sub Menu
- Recent Posts widget missing current_menu_item class
- WordPress custom Nav Walker
- In admin edit-menu screen, newly added menu items always go to the bottom of the list
- Static site menu with multiple ul’s to wp menu
- How to add scroll IDs to WordPress menu anchors
- WP nav menu + Bootstrap, add role=”menu” to UL
- how to check if given page is active page
- how to set the link in wordpress such that on clicking it doesn’t open another page but go to the bottom of same page
- custom walker class for own menu?
- 2 item in a same menu pointing to 1 page
- Add a menu metabox to post edit page
- Setting or plugin for showing submenus horizontally under the main menu, and keep them after selection
- New wp menu menu styling
- (Mobile) Hamburger menu disappeared from a page (only one)
- Hiding menu on specific pages
- Bootstrap Menu bar shows up a toggle in Desktop Mode
- For a menu custom link (without a link) a “#” is appended. Can this just be blank, i.e. NO link?
- sidebar navigation problem with child pages not all display.?
- How to point menu to my homepage
- save_post() on Menu Save
- code to add an extra selection to the menu editor
- Highlight inner post menu current item
- update_post_meta breaking wp_update_nav_menu_item
- Menu dropdown disapears behind slider
- Generate Submenu based on Parent Page using If Statement
- Building a menu from a large number of pages?
- how to change single post link
- Any simple way to show 10 previous pages by id to current page in links as a menu
- Accidental reverse order of menu items in one menu
- Pass $item->description to start_lvl
- Menu on responsive twentytwelve theme not working, strange url error
- How do I remove a menu from a theme?
- Access CSS Classes specified in Menu options
- Query for menus in backend (BE)
- How to output the menue structured for tabbed navigation?
- Add more levels to menu
- Custom Menu based off custom header
- WordPress Navigation
- Adding an additional menu in WordPress
- My Menu Disappears on my Custom Link Homepage on Mobile
- How to centre menu items on horizontal nav bar? (e.g. make margins equal) [closed]
- Display sub menus as separate lists