I solved it using ‘menu_order’:
function parent_menu_order($post) {
if( isset($post->post_parent) ) {
if($post->post_parent == 0) {
return $post->menu_order;
}// if no parent, return it itself
$post_data = get_post($post->post_parent);
return $post_data->menu_order;
} else {
return -1;
}
}
Related Posts:
- WordPress API Menu/Submenu Order
- inserting custom li class to wp_list_pages
- Custom Nav Walker Displaying Values in Sub Menu
- Custom Nav Walker to show siblings and children of current branch?
- Create self-populating menu and add extra divs to the menu layout
- Add theme templates for child categories into the template hierarchy
- Load child template based on parent
- Find the Children of a Page then Echo it as a Bulleted List of Links (menu)
- Custom Field returning Numerical Value for Image rather than URL
- wp_post->post_parent object returning 0
- Injecting a custom sql query into a page/theme
- Single-level menu option? Another way?
- How to display all subpages and short by year
- Admin: sub menu doesnt display under apperance when activate my themes
- Use a filter on menu items that have children
- Modify available templates (in dropdown)
- WordPress custom menu can’t show 3. level submenu
- Theme: dropdown hover menu not showing up in IE/Edge
- Show all menu levels except top level. How to exclude top level of a menu?
- WordPress menu walker – Get parent item text inside end_lvl function
- How to show children pages as array
- How to sort a sub-menu, generated with get_pages(), by the page order instead of alphabetically?
- WordPress doesn’t recognize submenus as so I can’t style them properly
- Main Menu Theme Different Output Print
- 404 on child page template
- How to create sub-menu in “Allure Real Estate Theme for Placester”?
- Add wrapper for a specific sub-menu
- Get the first image from post content (eg.: hotlinked images)
- Getting failure when using filemtime() with wp_enqueue_style
- Is it possible ( or advisable) to allow open access to the new theme customizer for potential clients?
- How bad is it if I write AJAX functions using wp-load.php?
- How to know if a child theme is being used?
- wp_nav_menu sort order?
- Twenty Eleven home page show only excerpt
- Snippet: Use classes instead of inline styles for text alignment
- Make a custom theme translate-ready
- Grab the first paragraph of each post
- Wrapper class: How to get rid of call_user_func_array() warning?
- Change Genesis Tag from Page Template [closed]
- How to Handle CSS for Multiple Header header.php Files?
- Resources for a complete beginner to learn to work professionally with WordPress [closed]
- Adding WordPress colorpicker in widget settings
- What is wrong with this code I have to make a blockquote shortcode
- Removing title tags from each page
- How to attach different React Components to different Dom Roots using the new WP wordpress/scripts webpack/babel
- Remove Cookies From WordPress Core
- Is it necessary to prefix every css class in a theme framework?
- Warning/Error in Admin Panel while developing theme
- How do I get the next page of posts link?
- Where can I access my custom page template?
- Logout hyperlink within a sub-menu
- How to display posts in hyperlink with nested slugs?
- Check if tag, category or author on archive.php
- Editing Footer Information
- How does a mobile WordPress theme differ from a simple theme?
- Developing WordPress Theme using CSS framework like Bootstrap
- How to add a button which saves the post then executes a function
- Disable dashboard drag&drop
- nothing happen in search form
- Catagories to the list of the titles in that catagory to the content of the post [closed]
- How to customize output of plugin
- Override customizer values on a per-menu base
- Theme Inspector “X-Ray”
- WordPress Theme Creation [closed]
- Cherry framework – Overriding function in template-general.php
- pagination for a custom loop with multiple post types
- Making a child theme for “Airi”
- How to get category lists by name or slug
- Preview returns 404 in theme [closed]
- Same comments on all posts
- How to get DB options format without saving? [closed]
- How to add custom page elements to the WYSIWYG editor?
- Theme development: menu links a tabbed page with page jumps
- Disable redirect canonical
- Show only pages you are author of
- how to unlocalize theme/plugin?
- Adding a button to wp/aution plugin
- WordPress and Semantic UI
- Displaying front side empty with one file attached problem
- Can you edit a theme in a text editor?
- Where i must put hooks in overridable functions?
- my ajax wont sent the data, please correct my code
- How to fix a conflict cause by my theme with Woocommerce and/or Gravity Forms?
- How to hook into wordpress upgrade procedure for a custom theme
- Second page of archive is empty
- Missing hashtag with theme customizer header color
- Fail to install theme on development copy of WordPress on Webmatrix
- how to make a new page affected by a theme’s index.php layout?
- Add custom field to existing meta box?
- Theme Options Doesn’t Work On WP Multisite
- WordPress two sidebar layout or theme
- add_action not working in header?
- Recent posts with comment count in “Sidebar” template [closed]
- HTML to WORDPRESS [closed]
- Feeds are showing where Post archive page should be
- My wordpress site memory exhausted more than 1GB trying to debug with default
- Display first post on each page differently than the others
- Custom Theme functions.php – Using add_settings_field and input type=”file” to set custom logo
- I want to resize post featured image without cropping image. How?
- Image and font support missing in editor when deploying theme remotely