Adding a unique ID to each sub-menu

As far as I can know about menus in WordPress – handlers use menu arguments. You can try to use this. Using the argument filter, we can pass the ID of the item: add_filter( ‘nav_menu_item_args’, function( $args, $item, $depth ) { $args->item_id = $item->ID; return $args; }, 10, 3 ); Then use custom argument anywhere. … Read more

WordPress Nav Walker – Top menu link with dropdown link not clickable (dropdown opens)

Managed to fix it by updating the following: $attributes .= ( $args->walker->has_children ) ? ‘ class=”dropdown-toggle” data-toggle=”dropdown”‘ : ”; // THE PROBLEM! to: $attributes .= ( $args->walker->has_children ) ? ‘ ‘ : ”; // THE PROBLEM! And the fourth $item_output to: $item_output .= ( $depth == 0 && $args->walker->has_children ) ? ‘ </a><b class=”caret dropdown-toggle” … Read more

How can I apply filters in my class that extends Walker_Nav_Menu?

apply_filters() applies a set of registered (with add_filter()) callbacks. When you apply a filter make sure its name is not one of the reserved ones, the_title looks dangerously “collissible” with other filters. Your filter application is almost correct, but the ‘modifyTitle’ bit is not required… // apply the filter apply_filters( ‘wpse31787_the_title’, $item->ID ); …instead you … Read more

How do I get_the_content in a custom walker?

For anyone who might be looking for the same thing, this is what I did in the end: I abandoned the Custom Walker idea and used wp_get_nav_menu_items to get a list of post IDs from my custom menu, from this tutorial on Digging into WordPress: http://digwp.com/2011/11/html-formatting-custom-menus/ In my functions file, I created this function: function … Read more

wp_nav_menu check both hierarchy fail?

This is correct behavior as far as I can tell, Imagine a scenario where you have a menu with top level items, Page A and Page B, each of which have Category 1 attached as a sub-menu item. Scenario 1 When viewing Post Example X, Attached to Category 1 And Where Category 1 appears twice … Read more

How to add a element with walker menu right after begin of the navigation tags?

The question is unclear but wp_nav_menu() has a couple of arguments that will allow you to add classes to the output. For example… wp_nav_menu( array( ‘container_class’ => ‘conclass’, ‘menu_class’ => ‘menclass’ ) ); You can alter those arguments using the wp_nav_menu_args filter as well. However, I suspect that when you say “class” you are using … Read more

Wrapping link and .sub-menu with wp_nav_menu

Ifigured it out myself, thanks to reading this: http://code.tutsplus.com/tutorials/understanding-the-walker-class–wp-25401 I created a custom walker: class Child_Wrap extends Walker_Nav_Menu { function end_el(&$output, $item, $depth) { $indent = str_repeat(“\t”, $depth); $output .= “$indent</div></li>\n”; } } And used wp_nav_menu: function main_nav() { wp_nav_menu(array( ‘before’ => ‘<div class=”child-wrap”>’, // before the menu ‘walker’ => new Child_Wrap )); }

New walker for walker_nav_menu to change inside container data

Well, you wouldn’t need a walker for that, if it’s simply adding a data attribute or something like that you could just use the items_wrap parameter. View wp_nav_menu() in Resources: $items_wrap = ‘<div class=”top-nav” mine=”something”>’; $items_wrap .= ‘<ul id=”%1$s” mine=”something2″ class=”nav %2$s”>%3$s</ul>’; $items_wrap .= ‘</div>’; wp_nav_menu( array( ‘container’ => false, ‘echo’ => true, ‘before’ => … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)