A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [walker]

The Walker class was implemented in WordPress 2.1 to provide developers with a means to traverse tree-like data structures for the purpose of rendering HTML.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

How to move all classes to the a tag in a walker?

I would like to add all the classes that WordPress uses in li tag and place them in anchor tag. So, I can place them in tab section of this code: <!-- Simple header with fixed tabs. --> <...
-1
votes
0answers
16 views

Add span inside each a tag in submenu menu-items wordpress

How to add span inside each a tag in submenu menu-items ? I presume I need to extend walker class but I'm new to walker class. In the following code I have sub-menu with 8 menu-items, I need to add ...
1
vote
1answer
39 views

How to dynamically add custom taxonomy terms as a sub-menu of an existing menu item, using custom walker class

Desired outcome I have a custom post type and belonging to it, a custom taxonomy. I'm trying to get my child theme dynamically add the terms belonging to that taxonomy as a sub-menu under a certain ...
0
votes
1answer
16 views

Displaying Nav Menu

I want to ask if this <?php wp_nav_menu( array('theme_location' => 'primary') ); ?> get all the sub-menu automatically? I saw this one of my downloaded theme and it displays all the submenu ...
0
votes
0answers
17 views

Stuck while adding bootstrap navwalker class

I am stuck while adding Bootstrap Navwalker class in WordPress. All is going well, but when minimize screen to mobile view the Menu disappear. However the Search box is still showing. header.php <...
0
votes
0answers
21 views

Different wordpress html menu markup?

I need to make 3 level menu. Dropdown tabbed style menu. The markup I get now is the default one: <div menu-container> <ul level-one-menu> <li> <a>Dropdown&...
0
votes
1answer
34 views

Is it possible to display the Navigation Menu without using Walker_Nav Class

I want to ask is it possible to display menus and submenus without using Walker Nav Class? I'm just to happen when I download a free theme using bootstrap and I do not see a start_el for navigating ...
0
votes
0answers
15 views

Drop down Nav Menu

I have tried to implement bootstrap drop-dawn nav menu, as Walker_Nav_menu, but no luck, start_lvl working just fine, but cannot add items to <div class="dropdown-menu"> element. Here is a ...
0
votes
1answer
33 views

What is inside in $item in start_el function in Walker_Nav_Menu class

I want to know what are exactly inside the $item in start_el function in Walker Class. Thanks in advance
0
votes
0answers
24 views

Multi-Level Nav Bar

Is there anyone here with a sample code for using walker class with multi-level function. I have a Nav walker class but it seems that it can only traversed to first element like this: <ul> &...
0
votes
1answer
27 views

Remove unwanted elements for a wp_nav_menu

I am working on building a custom mega menu within Wordpress.I am running into an issue with unwanted elements being displayed from wp_nav_menu which are distorting my menu. <?php wp_nav_menu( ...
0
votes
1answer
16 views

Adding additional html to the end of the root level in a custom nav walker

I have a custom nav walker, which essentially just add's new classes to the menu, however, my menu also contains some hard coded elements at the end (Contact button & Search Icon). Where/How to ...
0
votes
1answer
23 views

Does the Default theme of Wordpress like 2016, 2017 and 2019 uses Walker_Nav_Menu Class

I want to know if these themes uses Walker_Nav_Menu class. As I open the files I can't see a Walker_Nav_Class or I could not find it. And I want to know what they use to display the Menu and Submenus. ...
0
votes
0answers
107 views

Sub Menu does not display using Nav Walker

I have a submenu and I put a nav walker from a github source and my submenu does not display. Here is my code in header.php <nav class="navbar navbar-expand-md navbar-light bg-light" role="...
0
votes
1answer
19 views

Get Current Menu Location inside Nav_Walker

How can I retrieve the current menu location (as registered with register_nav_menus) from inside a nav-walker class? eg: <?php class Special_Nav_Walker extends Walker_Nav_Menu { // How can ...
0
votes
0answers
32 views

wordpress custom menu - show parents, siblings, children depending on depth

looking and trying for hours to find a solution for the following output of a wordpress custom menu. Hope you can help. I do not know where to start: custom menu walker, css, functions.php I have a ...
1
vote
1answer
36 views

start_lvl on Walker is not working

I'm creating a custom Walker to my menu, my code is like this: <?php class My_Walker extends Walker { function start_lvl( &$output, $depth = 0, $args = array() ) { $output .= "<...
0
votes
0answers
25 views

How to create a collapsible side menu using a walker?

I'm using wp_list_pages($args) to create a side navigation. I need to make the menu collapsible on mobile. Using a custom walker, 'walker' => new sidebar_walker(), within the $args and then class ...
0
votes
1answer
130 views

Wrapping menu's top-level link and sub-menus in div

I'm looking for a way to wrap a menu's top-level link and sub-menus into a custom div. I found this code that almost does the trick: class Sub_Wrapper extends Walker_Nav_Menu { function start_lvl(...
0
votes
0answers
25 views

Build Isotope filter groups with category terms

Sorry for the large question. I'm a bit lost and I want to provide all data possible for problem understanding. There are two options for achieve the goal. First, build the markup with a walker, ...
0
votes
1answer
43 views

Manual use of Walker_Category class

Trying to create a menu with category terms as I read in the WP docs "Using Walker Manually": https://codex.wordpress.org/Class_Reference/Walker $menu_items = get_categories(); $walk = new \...
0
votes
0answers
51 views

Custom submenu nav Walker

I am using a custom nav walker and would like to create a tree menu. Here is the HTML Structure for the full navigation <ul class="navbar-nav"> <li class="...
0
votes
0answers
30 views

Nav_walker add id to dropdown ul

I'm trying to add an id to the dropdown ul in bootstrap navwalker. So at the moment this is what I've got: <ul id="menu-primary-menu" class="list-unstyled components"> <...
0
votes
1answer
41 views

Insert menu with a custom walker into page / post body using shortcode?

I'm trying to add a menu using a custom walker class into a page or post body and settled on using a shortcode. I don't have to use a shortcode, but I do have to embed the menu into the central ...
1
vote
2answers
25 views

Trouble creating conditional PHP for nav menu items with children for custom Walker

I'm trying to create a nav menu with a clickable dropdown function but minimize scripting at the same time, so I found out a way to achieve this with an invisible input box and CSS. My only problem is ...
0
votes
0answers
21 views

Show Subcategories in Specific Menu item Using Walker Class

I want to show subcategories in specific menu item with custom div structure using walker class, My scenario is when I add a category in the menu from backend so show subcategories in that specific ...
0
votes
1answer
290 views

Walker class for sub-menu with ACF fields

Firstly, I'm wondering if this is the best way to even do this. I have a basic nav, one item has children. The children need to be wrapped in a container div and each child needs to pull some ACF ...
0
votes
0answers
30 views

Change markup for just 2nd list element in custom Walker menu

I have been struggling a bit with this idea. The thing I want to achieve is that all elements are regular dropdown but the second one is a megamenu styled item. And for that I have prepared markup ...
1
vote
0answers
177 views

Custom Walker_Nav_Menu issue with variables on PHP 7.3

I've made this custom walker that extends Walker_Nav_Menu for "mega menu" implementation. It works perfectly fine from PHP 5.4 to PHP 7.2, however it it has problems on PHP 7.3. The idea is to compare ...
0
votes
0answers
18 views

Use custom field content in menu-item

I'm making a mega-menu with some menu-items that can have a more rich content (from a wysiwyg editor using ACF custom fields). So, i have set an ACF field group to work with menu items, i need that ...
0
votes
2answers
113 views

Menu walker: how to tell if a sub menu contains submenus?

I mean: <ul> <li> <ul class="sub-menu"> <li> <ul> <li></li> <li></li> <li></li> ...
0
votes
0answers
38 views

Walker with sub-menu toggle

If I want a menu like this to work, how would I do it with a walker? I want to be able to include a button after the parent element, which toggles the sub-menu. Also, I must be able to put different ...
1
vote
1answer
158 views

How do I create page navigation linking to each H2 within the page? [closed]

I require each page on a WordPress site that I'm developing to have page-level navigation linking to each H2 on the page. How do I best automate this?
1
vote
1answer
34 views

Is this format possible with a custom Nav Walker class?

I'm looking to have the following output on a wordpress menu <nav> <a href="#">Link</a> <a href="#">Link</a> <aside> <a href="#" class="custom-class"&...
0
votes
0answers
17 views

Using walker to display all menu branches at once?

So i have need to get all submenus displayed at once on site and could use little help to customising walker for task. Menu displayed like this: menuitem1 menuitem2 menuitem3 menuitem4 sub1.1 ...
0
votes
0answers
40 views

Display parent title in sub menu

I have this type of menu : Menu 1 Submenu 1 Subsubmenu 1 Subsubmenu 2 Subsubmenu 3 Submenu 2 Subsubmenu 1 Subsubmenu 2 Subsubmenu 3 Menu 2 ... I want to display, only in the submenu, the ...
0
votes
0answers
22 views

Walker_Category - not reliably saving

I'm currently creating a custom Walker_Category class to make some changes to how category selection works in a custom taxonomy. The taxonomy is called 'page_category'. I want to put this in a normal ...
0
votes
1answer
54 views

Implement a Walker with custom object rather than Wordpress database object

I am trying to implement a Custom Walker to navigate through a hierarchy of objects. When I do a var_dump on the $item variable in the start_el function I see a wordpress database object (blog, page, ...
1
vote
1answer
252 views

Third level navigation class

I'm currently working on a third level navigation. The output should something like this: <ul class="menu"> <li> <a href="#">Level 1</a> <ul class="sub"> ...
1
vote
1answer
430 views

Function issue with Walker_Nav_Menu [duplicate]

I am getting this warning after updating to PHP 7.2 can anyone help me resolve it? Warning: Declaration of foundation_navigation::start_lvl(&$output, $depth) should be compatible with ...
0
votes
1answer
111 views

Difference between “Walker_Nav_menu” and “walker”

Does anyone know what is the difference between extending Walker_Nav_menu and walker. I learned about Wordpress Nav Walker and found several different tutorials. Do they extends different classes ?
0
votes
0answers
67 views

Where to place a svg chevron down in my custom walker?

i am a bit stuck with the custom walker in my Wordpress theme. I wanted to place a svg chevron down on the first link when a submenu is detected. My theme uses a svg file with all the svg paths. The ...
0
votes
1answer
351 views

Add parent menu item in sub-menu in custom nav_walker

Currently I'm working on a project where we need to append the parent title as first item in the submenu for a mobile menu. What I try to achieve is this: <ul class="menu"> <li> ...
0
votes
1answer
79 views

Custom Category Walker with Image, Fallback to Most Recent Post in Category Image

Based on this and this answer I am developing an extension of the Walker_Category which displays in image from an ACF field, falling back to the latest post's thumbnail. I have included the entire ...
1
vote
1answer
63 views

Dynamic_sidebar inside wp_nav_menu

I have Menu created by wp_nav_menu. Inside it, I want to set dynamic_sidebar but wp_nav_menu instead of displaying the content, throws 1. Have everyone some tips for display sidebar inside ...
0
votes
1answer
53 views

Wordpress customizing a walker menu class

Hey Folks I trying to customize a wordpress walker class to add custom classes to navigation level. Essentially there will be 3 levels of navigation. Here's the code: <ul class="rd-navbar-nav">...
1
vote
1answer
33 views

Put class on <a> instead li

I integrate a template into Wordpress theme. But I have a trouble with the menu. The menu come with class in <li> like <li class="nav-link"> if active <li class="nav-link active"> ...
0
votes
1answer
7k views

Add active class to wp_nav_menu

I'm using this code but it's not working function special_nav_class($classes, $item){ if( in_array('current-menu-item', $classes) ){ $classes[] = 'active'; } return $classes; } ...
0
votes
1answer
516 views

Remove a class from a <li> using Walker

I want to remove a class from 2 lvl depth,from li tags of ul class="sub-ul".How can I do that using Walker? <ul class="navigation d-block"> <li class="d-...
2
votes
0answers
26 views

Use walker for specific menu, or avoid use of walker

I'm trying to solve a particular problem and having trouble figuring out which way is best. So, I have a menu (generated through WP's menu creator) and would like to pull the featured image of each ...