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 )); }

Retrieve Menu name for nav_menu_item

The third argument passed to the filter are the $args used for wp_nav_menu: function wpse_147499_nav_menu_css_class( $classes, $item, $args ) { print_r( $args ); exit; } add_filter( ‘nav_menu_css_class’, ‘wpse_147499_nav_menu_css_class’, 10, 3 ); …which gives you: stdClass Object ( [menu] => [container] => [container_class] => [container_id] => [menu_class] => [menu_id] => [echo] => 1 [fallback_cb] => [before] … Read more

How to get menu location in wp_update_nav_menu hook

get_nav_menu_locations will give you menu IDs keyed by location which should correspond to the $id also passed with wp_update_nav_menu. add_action(‘wp_update_nav_menu’, function ($id, $data = NULL){ foreach( get_nav_menu_locations() as $location => $menu_id ){ if( $id == $menu_id ){ echo ‘location is ‘ . $location; } } }, 10, 2);

Output menu title

This outputs the title of a menu using wp_get_nav_menu_object (and prepends to the Content). function pg_show_nav_menu_title ( $content ) { // ID of the menu you want $nav_menu_id = 14; //Get menu into an object $nav_menu_object = wp_get_nav_menu_object( $nav_menu_id ); //Get the name (title) $nav_menu_title = $nav_menu_object->name; //String to return as Content $content=”Nav menu title: … Read more

Insert a div class inside wordpress menu

I think use Custom Walker. First register a custom navigation menu for this list in your theme’s functions.php class WP_Walker extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat(“\t”, $depth); $output .= “\n$indent<div id=’mega’><ul class=”sub-menu”>\n”; } function end_lvl( &$output, $depth = 0, $args = array() ) { … Read more

Where is the order of a menu saved in the database

You will get the nav_menu_items from wp_term_relationship in correct order. if you want to confirm there order by knowing there order number… u will get the object id of each item from the previous table and search for that id in wp_posts. then there will be column for that particular row named menu_order. so that … Read more

wp_nav_menu not displaying the right way

WordPress navigation menus won’t conform to styling or coding changes if they are being built by default. You have to actually go in and create the menu in Appearance > Menus and assign it to the menu location. After you do that, it should conform to coding/styling standards you set, as opposed to system defaults.