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
27 views

How to Display sub items if the Menu first level is Category selected in Nav walker

I have a problem in display nav walker. The code below is for a mega menu. In WordPress Menu When the first item selected is a category, it is not showing sub items. In normal mode, in depth=0 if a ...
0
votes
0answers
26 views

How do I add 3rd level of dropdowns to wp_nav_menu array?

How do I get 3rd level to show? <?php wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => 'collapse navbar-collapse', '...
0
votes
0answers
14 views

How to show only the last two categories in a menu?

I am working with many categories and their sub-categories (sub items). I felt the need for a customization, but I could not achieve exactly what I wanted. Normally, categories and sub-categories are ...
0
votes
1answer
31 views

Adding a unique ID to each sub-menu

I have the following menu via header.php: <?php wp_nav_menu( array( 'container' => false, 'theme_location' => 'primary', 'items_wrap' => '<ul class="...
0
votes
1answer
37 views

Add attributes to wrapper html generated by wp_nav_menu

I want to add some extra html attributes to the default div html generated by wp_nav_menu. I need to add simple code for example a short style code: style="top:10px;" I can't do what I am ...
0
votes
1answer
23 views

How to include second layer sub menu to Walker Nav?

I need to be able to access the sub-menus of the sub-menus on my nav. Currently I'm only able to access the first sub-menu layer. What do I need to add to access these? <?php class ...
1
vote
1answer
58 views

Create wordpress header with custom logo in between the menu splitting the menu into two equal parts [closed]

I would like to Create A Wordpress header with {the_custom_logo();} custom logo in between the menu splitting the menu into two equal parts so that the logo is always aligned to the center of the ...
0
votes
1answer
51 views

Adding markup to sub menu based on class

I would like to add a div at the after a sub menu. I would like to apply this change only if the parent menu item has a class name of product-menu (comes from CSS class field under menus section in WP ...
1
vote
0answers
25 views

WP Menu Walker - How to know total depth from inside the start_lvl() method

The start_lvl() method allows to know the current $depth parameter. But, I need to output different results at level 1 if the menu has x or y total levels. I did a print_r() of the $args array, but ...
0
votes
0answers
47 views

Help with Wordpress Custom Nav Walker

I want to convert my navigation menu in custom wordpress theme, I have created the design using html/css and now for the naviation bar I want to make it dynamic so it can be manipulated from wordpress ...
0
votes
0answers
19 views

Why is my navigation in my onepage not working?

I have a one-pager who has two sites. One is German and the other English. I made an own navigation for the English one, but it doesn't work. The navigation is throwing me back to the German one. The ...
0
votes
1answer
20 views

url_to_postid method in walker_nav navigation menu causing exceptionally high TTFB

I am using the walker class to create my custom mega menu, and using it to display post thumbnails at a menu depth of 2. It seems using the url_to_postid method seems to be causing a high ttfb of >...
1
vote
1answer
81 views

How to add ID attribute to each submenu?

I would like to add an ID attribute to each list <ul> submenu. I am using the Walker class extension. I have managed to modify some elements, but I am left to solve this one problem. I need the ...
1
vote
0answers
31 views

Why does the argument list_only do on Walker_Category_Checklist::start_el?

On the post edit screen there is the meta box for categories that utilizes the Walker_Category_Checklist class to create the category checklist within the meta box. One of the conditions (line 90 of /...
0
votes
1answer
117 views

How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?

On the Edit Screen in the WP Admin there is a meta box for WP's built-in Category taxonomy. This meta box is built using post_categories_meta_box() (/wp-admin/includes/meta-boxes.php). This meta box ...
0
votes
0answers
49 views

How to loop nav menu items in WordPress menu Walker?

I want to loop every single item in the menu with the walker class. class Primary_Walker_Nav_Menu extends Walker_Nav_Menu { public $bg; function __construct() { $this->bg = ...
1
vote
0answers
34 views

Automatically adding new post categories to menu

Disclaimer: I am not 100% fluent in php. If I am doing something wrong in asking this here, please let me know. Many thanks! A site that I am working on is set up with several custom post types: City, ...
0
votes
0answers
86 views

Bootstrap nav walker for wp_list_pages that includes dropdown links for child pages

I'm wanting to add a bootstrap menu to the sidebar that contains parent and child pages for a custom post type 'products'. I used the bootstrap walker I found here - https://gist.github.com/donchenko/...
0
votes
0answers
17 views

Is there a way to get comment number (count) in comment walker?

I'm currently building a walker for wp_list_comments() Is there a way to get the comment count (not comment number/id)? Or could I count the comments somehow? I know the ordered list provides ...
1
vote
2answers
65 views

Can't extend some core classes

I am relatively new to wordpress development, I am trying to extend 'Walker_Category_Checklist' class found in /wp-admin/includes/class-walker-category-checklist.php to customize it for ...
0
votes
1answer
226 views

wp_list_categories walker without links on categories that have subcategories (to make a nested dropdown menu)

I'd like to make a custom walker that works with wp_list_categories to generate a menu of nested uls using my category, sub-category, and sub-sub-category(?) structure. Any category that has sub-...
0
votes
1answer
61 views

Is it possible to get_the_post_thumbnail (Featured Image) inside a sprintf function?

I am trying to add the featured image of posts to my mega menu. I want to display the featured image inside a div tag. How would i add the featured image inside of a sprintf function? $thumbnail = ''; ...
0
votes
1answer
23 views

How can I creat custom menu with bootstrap

I'm trying to create bootstrap collapsing navbar for WordPress template. I have to add some HTML properties such as data-toggle. After researching, I found that must customize the Walker class but ...
0
votes
1answer
564 views

Wordpress menu walker - help to add custom class for each submenu

I am trying to apply to my already existing menu a walker in order to add custom classes to every sub menu anchor tag. Here is my menu: wp_nav_menu(array( 'theme_location' =&...
0
votes
0answers
75 views

Need help with Walker_Nav_Menu class

I am trying to learn how to use walker_nav_menu for past week but can't find the right material. WP documentation just cover simple definition of walker nav menu class. And most of the resources i ...
0
votes
2answers
439 views

How to remove an item from a custom Walker_Nav_Menu

I have a custom menu on a wordpress + woocommerce site using the Walker_Nav_Menu class. When hiding posts (products) from the site those posts and category are still included in the custom menu. I ...
0
votes
0answers
25 views

Structuring Nav Menu and Background Custom page (Help)

i´m creating theme is my first theme and i have a problem with panel nav menu of wordpress, I´m creating the order of nav menu in the panel wordpress and does not order, i was make page and ...
0
votes
0answers
128 views

Can I now add a class in the anchor of my menu item with Wordpress 5.4?

I am using the following code in my functions.php file: function add_menuclass($ulclass) { return preg_replace('/<a title="All"/', '<a title="All" class="addition-of-class-name"', $ulclass, 1); ...
0
votes
0answers
53 views

why are my walker menu is showing like this?

<?php /** * The second Header template for our theme * * Displays all of the <head> section and everything up till <div id="main"> * * @package WordPress * @subpackage ...
1
vote
0answers
34 views

How to create this Custom Walker Menu

It's the first time I'm trying to create a customized menu Walker. I'm following a very specific HTML. I searched and tried different things. Days have passed and I still can't get it right, but I don'...
1
vote
1answer
774 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
19 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
39 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
1answer
210 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
1answer
183 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
494 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> &...
1
vote
1answer
127 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
175 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
34 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. ...
1
vote
0answers
776 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="...
1
vote
1answer
280 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
123 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
624 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
1answer
1k 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
1answer
135 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
59 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
260 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
128 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
1answer
858 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
72 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
2 3 4 5
8