Show Child of Parent Page including all other parents

‘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

Update nav menu not selecting parent

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

Can’t add any menu items anymore, server related

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

Hide menu theme location for certain capabilities?

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

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

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