Articles of menus

How can I put two menus in the same div?

I’m converting an html5 site into a wordpress theme, but have got stuck with my menus! this is the html version: And this is my result so far in wordpress: as you can see I can’t get the social menu inline with the main menu! This is the function.php bit: function register_my_menus() { register_nav_menus( array( […]

Get number of root elements in walker class

I extended Walker_Nav_Menu class as below class YPE_custom_navwalker extends Walker_Nav_Menu{} I want use the get_number_of_root_elements( $elements ) function that place in to Walker class within my new class YPE_custom_navwalker i want use that function for showing the number of root elements within start_el function i used this code below but don’t work echo $args->walker->get_number_of_root_elements($elements);

Unusable menus and “Illegal widget setting ID: nav_menu_item” error

This is a bug in my WP install that has crept up unknowingly; I can’t say for sure when it began. To describe it: there were menus created in the Appearance -> Menus page early in the site’s history, and they work perfectly, as in: They have menu items They can be assigned to menu […]

Edit menu item title from edit page/post

After we save a post/page, a new menu item is created (with the same title) in the navigation that we have created in nav-menus.php. If we need to change the menu item title, we need to go to nav-menus.php and change it to something else. Is it possible to have some text field, for example […]

Outside the loop, how can I echo the current page's menu title?

I have no idea why I’m finding this so hard. I’ve gone through many similar posts here, but none are working. I am building a menu outside of the loop on my index page – it a standard posts page, not a static page set as home. Basically, I want the current page’s menu title […]

Custom walker with hashes instead of links (one-page layout)

I am currently developing a one-page based layout with WordPress where the actual content is split up into separate pages in the backend, which are all knit together to a one-page layout in my front-page template file. The WordPress menus allow for custom URLs which is probably the easiest way to cater a one-pager by […]

has_children in custom nav_walker

I am trying to create custom menu nav walker. I added below code function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields[‘id’]; if ( is_object( $args[0] ) ) { $args[0]->has_children = ! empty( $children_elements[$element->$id_field] ); } return parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } As a result I can […]

JSON file export of nav menu

I am trying to export the essence of my wordpress site’s menu in json notation. I want to extract some details like id, type, name, sub-item and want to construct a Json object like below. Item – { id: ‘wp entity id’, name: ‘name of the category|taxonomy|post|page’, type: ‘post|category|page’, children: [array of Items] } where, […]

How can I add divs or change li in the submenu of the menu_nav

I want to add divs and classes to child [ li ] elements that come after [ ul class =”sub-menu” ] of the parent [ li ]. The problem is, when I try to modify the [ li ] in the start_el function, all [ li ] get modified, even the ones that are outside […]

How To Remove Duplicate Menu Locations

I am creating some menus but when I go to the menu dashboard It shows up as “Nice Name” and the ‘Menu Name’ does anyone know how to prevent this or remove it? I attached photo to illustrate what I mean: I add my menu in my function.php like so: add_action(‘init’, ‘register_menus’); function register_menus(){ // […]