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
1
vote
1answer
1k views

automatically placing custom post types singles into submenu of main nav menu

I'm looking around and see some hints at what I'm wanting to do may be possible, but it's just not clicking for me. I have a custom post type rt_doctors. I'm trying to make it so there will be a ...
1
vote
0answers
87 views

WordPress Walker - Group two items?

I'm using the built-in WordPress wp_nav_menu() and a custom walker to loop through items for a footer nav menu. I understand that a Walker essentially loops through a nav menu, formatting each element ...
1
vote
1answer
495 views

WP Walker using custom css classes

In order to make a navigation (from scratch), I've been altering the output of the walker. Currently i am trying to find a way to include the 'Optional CCS Class' (found in Appearances -> Menu's in ...
2
votes
2answers
5k views

Simple Navigation Walker – Wrapper-class around first sub-menu

I'm trying to wrap the first sub-menu of a navigation into a seperate div. None of the children or sub-levels should get the same treatment. I'm really new to the Nav Walker-thingie and I'm really ...
0
votes
1answer
294 views

Hooking to walker_nav_menu_start_el to insert list of subpages

What I want If a 'category' is added to the menu using the 'menus' tool in WordPress, I want my theme to automatically add a submenu containing links to all of the posts in that category. <ul> ...
1
vote
1answer
76 views

Difference between walker class and basic php

I started to work with Walker class days ago and I still have this simple question: When building sub-menus and drop-down menus, what is the difference between using Walker class to build it, or ...
2
votes
3answers
7k views

Nav walker, bootstrap: Display 3rd level items under 2nd level

I am using the WP_bootstrap_navwalker for a dropdown menu. This works fine, but it only shows me the first and second level items. So de dropdown on the first level and a regular second item when ...
2
votes
1answer
483 views

How to display dynamic content in start_lvl function

I am creating a custom nav walker but having trouble outputting parent menu item title in start_lvl function. I want to output it right after the <div class="dropdown"> in the following ...
2
votes
1answer
3k views

Add Page ID class to nav menu items

I would like to add classes containing the page id numbers to the <li> items in my nav menu. Similar classes are generated by wp_page_menu() but for some reason they're not generated by ...
0
votes
2answers
276 views

Show Sidebar Menu Subpages When Clicking Parent

I have a sidebar nav menu set up to display the top level pages. I'd like to display subpages (3rd level) when a user clicks on a parent item. For example, when then user clicks 'Detective Division' ...
1
vote
1answer
656 views

How to add a <span> tag to wp_nav_menu in a child theme

I'm creating a website with WordPress and Uncode theme, and I want to add a <span> tag to the primary menu in the child theme (in the 'li', after the 'a') and I don't know how to do that. I don'...
1
vote
2answers
918 views

Adding post excerpt into navigation menu

After each menu item, I want to add the page excerpt underneath it. So if i have a menu that looks like this: Home About Contact I want to get the page excerpt into the menu like this: Home This ...
0
votes
0answers
124 views

Conditional Nav Menu Inside Nav Menu Across Multisite Sites

I am attempting to use the main site menu across a bunch of sub-sites in a WordPress multi-site configuration. The sub-sites use the main site's navigation. However, I want to omit one tree of links ...
0
votes
1answer
72 views

Customize existing menu item

I am trying to manipulate the existing primary menu with a plugin. The result should be: if the plugin is activated, it edits the 'Login' button to be conditional: if something is true show ...
0
votes
1answer
473 views

How to add odd and even classes to all nav links through walker?

I kept finding posts that explain how to add even and odd classes to sub-menu items, but can't seem to find how to add it to the main menu items that do not have sub menus. I've already checked out ...
0
votes
1answer
43 views

Output sort number in wp menu list item?

I want to output the sort number of the list item in it, in the wp menu. No, not by using ordered list <ol>. I have tried search for answers about this by searching on wp forum an reading the ...
-1
votes
2answers
3k views

How to add attribute in menu code

I want to make a menu with hover animations. My HTML syntax looks like this: <ul class="menus"> <li class="current"><a href="#" data-hover="Home">Home</a></li> <...
3
votes
0answers
47 views

Render Selected Categories in Admin Edit Post Screen differently

Selected Categories for a post in the admin screen are rendered by: // Put checked cats on top $output .= call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) ); ...
5
votes
2answers
72 views

WordPress 4.4+ breaks Walker Extension

I upgraded WordPress to 4.5.1 from 4.2.2 and it has broken the functionality I have extending the Walker class. The Walker extension: class ReturnWalker extends Walker{ public $db_fields = array( '...
3
votes
1answer
903 views

Pass a parameter to a menu walker

Is there any way to pass a parameter to a menu walker? I'm trying to write a BEM-style walker, and I'd like to be able to pass a class to apply to the menu links via the walker. Something like: <?...
0
votes
0answers
83 views

Nav walker class error on WordPress update [duplicate]

I updated my WordPress to Version 4.5 yesterday, and the below warnings were show Warning: Declaration of Walker_Nav_Menu_Dropdown::end_lvl(&$output, $depth) should be compatible with ...
0
votes
2answers
1k views

How to request container_class from wp_nav_menu

I'm currently trying to setup a custom nav walker that will use container_class from the menu as a prefix for the class names of the list items and children. $defaults = array( 'menu' =>...
0
votes
1answer
386 views

Custom menu with Walker class - what should the $db_fields be?

I'm trying to create my own custom menu using the Walker class and in the process of trying to figure out what's going on, I'm attempting to reproduce what wp_nav_menu() does by default, so, I've got ...
2
votes
1answer
1k views

Add div to specific sub-menu

I researched in google, yandex but had no success. With this code I can set a div to sub-menu but this code add to all sub-menus, I just need to add div to specific sub-menu. class Megratron_div ...
0
votes
1answer
632 views

Assign different category colours to different categories in the main menu

I have created a colour picker field with ACF which shows on every category page and allows the end user to assign a colour to each category. This is working well but I would like the categories on my ...
0
votes
3answers
140 views

Cannot add home page url to menu with #

I am adding a #section as a custom link to my menu, because I want to scroll to that section when I click on that link. When I'm on the home page, this works fine (the section is on the home page), ...
0
votes
1answer
427 views

Where to implement custom walker class?

I have created a custom walker class for changing the output of menu items. Where do I place my custom walker class file at? I have tried to ask on the Wordpress forum but it has gone 3 days with no ...
0
votes
1answer
822 views

New walker for walker_nav_menu to change inside container data

I'm not really good with coding, but I have googled a lot and edit some script and it worked, but I can't achieve what I need. This is the code: class description_walker extends Walker_Nav_Menu { ...
6
votes
2answers
4k views

Comment Walker vs. Comment Callback

I've been messing around with custom comments this week and I'm trying to figure out when I'd want to use a walker and when I'd use a callback... There's some things I can't quite figure out how to ...
4
votes
1answer
9k views

Add class to top level menu item if it has multiple child levels

I have a WP nav menu, and I need to add a class to any top-level <li> if that item has more than one level of child items (meaning, its child submenu has a submenu too). Like this: <ul> ...
1
vote
1answer
1k views

Main Menu and Sub Menu Items for Footer

So I'm currently trying to figure out how to display both my main menu items and my submenu items separately in my footer. I want to display them both in separate columns (bootstrap) and am having ...
1
vote
0answers
62 views

custom walker class

I'm trying to make a navigation that has a similar structure of this website: https://grannys.ca/ But I got struck in the logic of how can I implement an if statements which determine several things: ...
1
vote
0answers
224 views

Custom navigation structure with walker class

I'm trying to make the navigation with different structures using walker class but I got stuck. Here's the code of what should the html output <nav class="main-nav"> <div class="...
1
vote
1answer
3k views

add span class and i tag inside wp_nav_menu link anchor tag

I found examples adding a class to top level items, so we can display an arrow in menu items with sub-items, but is seems terrible to cope with the already built in WordPress classes, can't display ...
1
vote
0answers
437 views

Create menu / submenu from category subcategory and posts

I have a custom menu made up of pages and categories and I am trying to output the category and subcategories as well as the last 4 posts from each category/ subcategory. In trying to use a walker ...
1
vote
0answers
21 views

Navigation doesn't render when wp is hosted

I have created a theme on my local host and it works fine. I am using the walker function in order to get the bootstrap navigation. However when I upload the site on godaddy the navigation doesn't ...
1
vote
0answers
258 views

CSS_Menu_Walker not showing on mobile view?

I found this example on perishable press. My menu works fine and all the submenu items display properly. For some reason, when scaled below 769px, it disappears. I figure it's CSS, but I can't make ...
2
votes
1answer
1k views

`start_el` depth argument in custom nav walker always evaluates to zero

I have a custom nav walker I'm trying to use to output only the first level of a menu: <?php wp_nav_menu( array( 'theme_location' => 'secondary-menu', 'depth' => 1, 'walker' =>...
0
votes
1answer
57 views

Show post titles within Wordpress bootstrap Dropdown menu

I created custom bootstrap navwalker class for my wordpress theme all things work correctly i has this code below within function start_el(){} When i put <h2>Hellow World!</h2> within $...
1
vote
3answers
6k views

wp_nav_menu add class to child item with sub child

I need your help, am trying to add class dropdown-submenu to a <li> element which has children. Not sure if I was clear enough, so here is an example: |-Home (Parent Item) |-Services (...
1
vote
1answer
266 views

Get number of root elements in walker class

I extended Walker_Nav_Menu class as below class YPE_custom_navwalker extends Walker_Nav_Menu{} I want use the get_number_of_root_elements( $elements ) function that place in to Walker class within ...
0
votes
2answers
560 views

Set custom id to list element walker custom function

I am creating a navigation with bootstrap in a custom WP theme. I have managed to get this result: <li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-...
1
vote
0answers
408 views

Custom Navigation build using wp_nav_menu and walker

What I have Right now I have an old template in plain HTML. In there I use a custom Navigation menu built like this: <div class="collapse navbar-collapse main-menu main-menu-1" id="main-menu"> ...
0
votes
1answer
343 views

How can I make wp_nav_menu() support <br> tags?

Static webpage created nav menu separating titles using <br> tags, but when I'm converting the site into WordPress I'm missing <br> tags there. How can I enable using <br> tags in ...
0
votes
1answer
3k views

Counting top level items in a custom menu walker

I am creating a split menu (half the items on the left, logo in the middle, remaining items on the right). I don't really understand Walkers all that well, but I found this code snippet. This was ...
1
vote
0answers
280 views

Extend Walker Class for 2 checkbox taxonomy selection?

I am working on an add-content front end form (posts in this case). I am able to display, and add, categories and taxonomies to posts correctly with the following: <div class="checkbox"> &...
0
votes
0answers
173 views

Add parent link to its submenu

How to add parent link to its sub menu in navigation bar? I mean any hook, filter or custom navigation Walking? You may know, this problem is coined from the feature of mobile menu, I cannot go to ...
0
votes
2answers
726 views

How to Add support for sub-menu item description in wordpress?

I am working on a Custom Nav Walker and I want to use Description field in wordpress menu in my theme. The field works fine as far as for First Level Menu items but when I add something in sub-menu ...
0
votes
1answer
131 views

Is it possible to separate all submenu items?

I'm using FoundationPress as a starter theme and I'm trying to separate the submenu. My theme basically generates menus like this: <ul> <li class=" first-level has-dropdown"> &...
2
votes
1answer
270 views

Custom Walker anchor tag not inheriting attributes

So I am just now learning and playing with custom walkers and I came across this really helpful Stack Overflow question. So I implemented the answer in that answer and added this to my functions.php ...

1 2
3
4 5
7