Get menu items problem

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

Importable Menus? Along with Pages (a site layout template)

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

Pass $item->description to start_lvl

// 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

Menu item hidden behind others

You are correct that this is definitely a CSS issue. To get the 3rd level menu to show up fully, you’ll want to target it and move it X number of pixels from the left until it lines up correctly. If your sub-menu’s have a set width, then use that set width to move the … Read more

wp_nav_menu not selecting teh correct menu

I faced the same issue and finally got the answer: For functions.php: register_nav_menu( ‘primary’, __( ‘Navigation Menu’, ‘Removemymug_Theme’ ) ); register_nav_menu( ‘second-menu’, __( ‘Second Menu’, ‘Removemymug_Theme’ ) ); For Secondary Menu (Footer): wp_nav_menu( array( ‘menu’ => ‘second-menu’, ‘theme_location’ => ‘second-menu’, ‘depth’ => 2, ‘container’ => ‘div’, ‘container_class’ => ‘navbar-collapse collapse’, ‘menu_class’ => ‘nav navbar-nav navbar-right’, … Read more

add custom entries to menu options

Here a very quick example. The idea is to add a new meta box in the menu configuration. add_meta_box is used in admin_head-nav-menus.php page: class Custom_Nav { function __construct() { add_action( ‘admin_head-nav-menus.php’, array( $this, ‘add_nav_menu_meta_boxes’ ) ); } public function add_nav_menu_meta_boxes() { add_meta_box( ‘custom_links’, __(‘Custom links’), array( $this, ‘nav_menu_link’), ‘nav-menus’, ‘side’, ‘low’ ); } public … Read more

WordPress menus – automatically generate

Use the WP database (via proper methods) to store a ‘is this the first run’ flag? Then just conditionally execute. check for flag in wp db if exist do nothing if not exist create me my menus dag nammit remember to set flag for next round so its only done once Something like that? If … Read more