So you need to real name and URL of the parent in the submenu.
You have no info about a post item in your function start_lvl()
.
But in function start_el()
you have the items and could query for it’s parent.
This needs some refactoring with putting lines like the if($display_depth > 0){
condition from start_lvl
function into your start_el
function. Then writing a proper WP query to get the Info’s of the parent item you need in the submenu.
To point a bit more specific:
In start_el
function you have the var $item
which should contain the ID of the post it represents. Should be $itemId = $item->Id
.
If so you should get the parent with $parentId = wp_get_post_parent_id( $itemId );
and further more you can fetch infos from the parent with the parent ID with some other WP functions.
Hope that helps to find your way..
Related Posts:
- Mega Menu Walker
- start_lvl Ignored in Custom walker_nav_menu
- Run a filter when a walker runs
- Automatically adding new post categories to menu
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Add login hyperlink to secondary navigation menu
- Displaying Logged-In User Name in WordPress Menu
- Hide main div if wp_nav_menu is empty
- Check if a menu is empty?
- How to remove a metabox from menu editor page?
- Walker class: Problems with understanding how walk() method can be called without error
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to add active class to custom menu using while loop and wp_list_pages
- WordPress menu deletes when trying to add a hook
- Logout and redirect using the WP Menu
- Have CSS Class Added with `is_page()` WP function
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Can’t extend some core classes
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- Menu — How to add “current-menu-grand-ancestor” css class
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- WP Walker using custom css classes
- Add data attribute to each li in menu
- Custom Walker_Nav_Menu issue with variables on PHP 7.3
- Unique icons next to each WordPress menu item
- Child page menu in sidebar
- Title Case WordPress Menu Items
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Trying to store submenu items to render out after main menu
- How to change menu order item
- Add item to top of menu using a filter in functions.php
- Register a menu – Error Header
- New walker for walker_nav_menu to change inside container data
- Add value to new attribute inside WordPress menu items
- How to display different submenus?
- Get the name of menu item with wp_nav_menu
- How to add aria role and schema markup to custom walker container
- How can I use custom menus with a Bootstrap WordPress theme?
- Extend Menu Walker Output
- Nav-Menu not showing up
- Remove submenu item from list
- Dynamic Menu drops pages?
- Menu not styling. New menus functionality giving me a headache
- Nav Walker that shows only children and siblings of top level parent menu item
- how to changes mobile menu toggle breakpoint in WordPress
- How to display already created menus via php?
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Adding markup to sub menu based on class
- How to put 2 php codes in functions.php without site crashing
- Menu not updating for logged in users after redirect
- Add element after navigation element title don’t works like I expect
- Difference between “Walker_Nav_menu” and “walker”
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Pulling a variable into the wp_nav_menu function
- How I can add div to menu?
- Add the “.current-menu-item” class to tag?
- WordPress adding in site URL to header links
- Custom Links in Walker Class
- I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- How to add different menu items on different menus?
- adding a filter to a shortcode?
- Change the footer text on the login page
- Rewriting search and pagination base
- Copyright info change in Theme Child PHP
- How to place login logout link on menu that redirects users back to current page?
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Create an array from an array
- Can I change a variable in a content part while calling it?
- Shortcode return function with link href inside PHP
- Can’t get page content in WordPress
- How to call plugin function per site in a multisite?
- Noscript not working as it should in wordpress site
- Pagination broken on is_front_page()
- Missing a text-domain esc_attr_e
- Extract and display user infromation on an automatically created page
- Add class to ul and li in wp_na
- Execute PHP code only with specific user role
- PHP function for horizontal Woocommerce thumbnails and badges
- Is there a PHP function that will return the block ID generated by WordPress?
- Creating a Function and Call It
- WooCommerce display price before add to cart [closed]
- Show sidebar only to author of post
- how to add custom select field to wordpress edit page
- All categories options or All categories not Populating
- WordPress load javascript file if something… (after the page is loaded)
- Wrapping shortcode content in a span or link
- Permission functions within wordpress
- WordPress display name string manipulation
- How do I modify the with wp_nav_menu()
- which table updated after logout?
- Accessing WordPress Functions get_permalink() in Vanilla PHP?
- Saving User Input to PHP Variable
- Show div only if product has attribute
- Frontend redirect after delete post in wordpress
- In WordPress how do you remove render-blocking CSS manually without a plugin?
- Link on post title only if post have content
- How to save a post to a Custom post type and copy the information to another Custom post type?
- Is there a hook that I can use when a fatal error occurs?