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.
351
questions
1
vote
0answers
14 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
9 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
13 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
25 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
50 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
0answers
21 views
Wrap <div> around navwalker elements
So I'm having some issues and I can't figure out how to solve them, I've recently started working with WordPress navwalkers and I'm stuck on a particular piece and I can't figure out how to get around ...
0
votes
0answers
10 views
wordpress nav walker with two seperate uls for 2nd and 3rd level
I need to create a menu structure where the third level ul isn't nested into it's parent li.
It should be after the 2nd level ul, like show in the following code example:
<ul>
<li>
...
0
votes
0answers
7 views
How to sort comments by answers given in single comment
$comments = array(
'post_id' => get_the_ID(),
// 'status' => 'approve',
// 'hierarchical' => 'flat',
'orderby' => 'meta_value_num',
...
0
votes
0answers
30 views
Custumise Nav Walker sub-menu : adding HTML content like effect in mega menu
I need to custumise my walkermenu in wordpress, but i have an issue with it, this is my menu structure, I need to add, a div after my ul sub-menu, like the ffect in mega menu :
<nav class="...
0
votes
1answer
28 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
0answers
21 views
Mega Menu Walker Add Description
I'm using a custom walker to display a mega menu. I've enabled Descriptions in the menu admin but I can't get it to display in my menu. My description is on the parent item but I need to display it on ...
0
votes
1answer
20 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
0answers
10 views
How to apply a class to nested sub-items of a menu?
I am trying to replicate this drop-down menu in a Wordpress theme:
But I've spent my whole week to only get this result:
(The sections items are properly handled, but their sub-items are a mess! "...
0
votes
1answer
200 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
19 views
Fix custom walker to show custom fields
I have a custom walker that adds a mega menu to my theme. At the bottom right of each mega menu I need to put custom text via a custom field or widget that is going to be different for each mega menu. ...
0
votes
0answers
44 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
187 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
16 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
102 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
36 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
31 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
480 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
26 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
151 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
103 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
213 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
62 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
73 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
33 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
473 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
114 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
62 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
379 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
670 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
94 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
46 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
135 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
90 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
616 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
53 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
258 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
2answers
378 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>
...
1
vote
1answer
159 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
51 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
18 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
25 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
64 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
749 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
1k 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 ...