Articles of walker

Extend Menu Walker Output

I’ve found a custom Menu Walker on the Internet that was perfect for my multilevel menu. It fitted almost like a glove. I’ve made some tiny improvements but now I need to limit the number of characters inside the output: <li><a href=”http:\\…”><span>Blah Blah Blah Blah Blah Blah Blah Blah Blah</span></a></li> I’m having some problems to […]

Custom nav walker with different output depending on depth

I am trying to redevelop a HTML site as a WordPress theme, and the HTML menu is as follows: <ul> <li class=”current”><a href=”#”><div>Home</div></a></li> <li><a href=”#”><div>Link 1</div></a> <ul> <li><a href=”#”><div class=”flintstone-nav”>Sublink 1</div></a></li> <li><a href=”#”><div class=”flintstone-nav”>Sublink 2<br><div class=”flintstone-nav-small”>Smaller Text</div></div></a></li> <li><a href=”#”><div class=”flintstone-nav”>Sublink 3<br><div class=”flintstone-nav-small”>Smaller Text</div></div></a></li> </ul> </li> </ul> I have removed the default menu wrapper and default […]

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-27″>…</li> However I have already styled my navigation before transforming it to WP navigation like this: <li class=”” id=”nava”><a href=”–><?php //echo get_option(‘home’);?><!–/”>Home</a></li> I want to replace id=”menu-item-27″ with id=”nava”. Any help […]

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 wp_nav_menu().

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 { function start_el(&$output, $item, $depth = 0, $args = Array(), $id = 0) { global $wp_query; $indent = ( $depth ) […]

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’ => ”, ‘menu_class’ => ”, ‘menu_id’ => ”, ‘container’ => ‘nav’, ‘container_class’ => ‘nav-primary’, ‘container_id’ => ”, ‘before’ => ”, ‘after’ => […]

Custom menu walker – remove li tag based on class name

I’m using wp_nav_menu() to display menu items with a custom walker. <ul> <li id=”menu-item-799″ class=”menu-item … custom-theme-class”><a href=”#”>custom content</a></li> <li><a href=””></a></li> <li><a href=””></a></li> … </ul> Now I’d like to change the li output depending on a class name. I use something like this: function theme_function($item_output, $item, $depth, $args){ $output = ”; // Overview Menu if […]

How to convert the argument of wp_list_pages to an array

I am working on a theme that calls wp_list_pages(‘title_li=&sort_column=menu_order’) I need to put a walker class in that but the conditions has to be same. I don’t understand what ‘title_li=&sort_column=menu_order’ means and how to convert it to an array with the option to add a walker class ?

wp_nav_menu: Is there a way to modify the output of <a> that got a submenu?

With some preg_replace, I can replace some classes in the wp_nav_menu, so one of my menu (which has submenu) now looks like this. <li class=”nav-item nav-item-has-children dropdown menu-publication show”> <a class=”nav-link” href=”#”>Publication</a> <ul class=”dropdown-menu”> <li class=”nav-item menu-book”> <a class=”nav-link” href=”#”>Book</a> </li> </ul> </li> However, I also need to replace the <a> element (the .nav-link) so […]

how to change WordPress menu markup/classes

I’m building my first website on WordPress, and i wanted to ask is someone know how to change markup in WordPress menu. Basically I want the markup of my WordPress navigation to match what I’ve done in my static templates. <div class=”topNav”> <ul> <li><a href=”#”>About</a></li> <li><a href=”#”>Mes siūlome</a></li> <li class=”dropdown”> <a class=”dropbtn”>if Has subMenu</a> <div […]