Can’t add optional class to menu item when using Walker_Nav_Menu
Can’t add optional class to menu item when using Walker_Nav_Menu
Can’t add optional class to menu item when using Walker_Nav_Menu
‘depth’=>-1 will show all the levels (source^): $depth (integer) (optional) How many levels of the hierarchy are to be included where 0 means all. -1 displays links at any depth and arranges them in a single, flat list. Default: 0 So your code will be: <?php if (has_nav_menu( ‘secondary’ )) { wp_nav_menu( array( ‘container’ => … Read more
As I originally suspected, menu-item-parent-id takes the id of the menu item and not the id of the parent page. So I referenced the menu item ID and passed it into the recursive function : function buildMenu( $array, $menu_id, $parent_id = false ) { foreach ($array as $menu) { $menuItemId = wp_update_nav_menu_item( $menu_id, 0, array( … Read more
While it is a guess, rather than certainty, the issues with menus typically boil down to following — working with them involves submitting large and complicated POST requests to server. And what on server has issue with large and complicated POST requests? Security software! The first item to check in such case is usually going … Read more
Check user capabilities or roles when registering the navigation menu. The data will remain accessible via wp_nav_menu, but users without the capabilities won’t see the location in Appearance -> Menu -> Manage locations. Note this will only prevent assigning menus to these locations. Any menu assigned to the location already will be manageable (if the … Read more
I tried with the name and the slug and different menus but I always find that error. Did you try with location slug? Take a look at where your menu location is defined (functions.php), for example: register_nav_menus( array( ‘primary’ => __( ‘Primary Menu’, ‘mytheme’ ), ) ); On Appearance->Menus assign your menu to that location. … Read more
Admin Custom Menu Editor Disappeared
There are a few code edits you might have to do.. So lets go step by step.. Change in the places you use, <?php echo esc_url( home_url( “https://wordpress.stackexchange.com/” ) ); ?> to get the home page url, you can replace it with <?php get_site_url(); ?> which will get you your site URL. Next you are … Read more
Menus are included in native WordPress export. It’s not too convenient that natively you can’t only export menus though. From quick look up there is WordPress Menu Exporter plugin available in official repository for that. Export/import aside there are more options to automate it, such as set up scripts with WP CLI or simply using … Read more
// Get menu description as global variable function add_menu_description( $item_output, $item, $depth, $args ) { global $description; $description = $item->post_content; return $item_output; } add_filter( ‘walker_nav_menu_start_el’, ‘add_menu_description’, 10, 4); // Submenu walker to add image class submenu_walker extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { if(0 == $depth) { global … Read more