automatically adding submenu items
automatically adding submenu items
automatically adding submenu items
Got it to work, finally! Nothing like a good sleep to restart your brain 🙂 Updated code that works: $item_output = $args->before; if( $item->object == ‘category’ ) { $category = get_category( $item->object_id ); $category_color = get_field( ‘category_color’, $category); $item_output .= ‘<a style=”color:’ . $category_color . ‘;”‘. $attributes .’>’; } else { $item_output .= ‘<a’. $attributes … Read more
Yep, I’ve got the solution to this problem. You can retrieve number of child items right from menu_items retrieved by wp_get_nav_menu_items. This function retrieves a bunch of post objects containing info about ‘menu_item_parent’. Inside start_el function of Walker_Nav_Menu class, you can try the match agains $item->ID. This way: $locations = get_nav_menu_locations(); $menu = wp_get_nav_menu_object( $locations[‘primary’] … Read more
Getting stripos error when trying to add menu classes
Some digging around led me to find that all the items were marked up with the class sub-menu which I was able to style in the CSS.
The menu items boxes are created by the class Walker_Nav_Menu_Edit in wp-admin/includes/nav-menu.php. Thus to alter those boxes you’ll have to make your custom Walker I guess. But if you mean adding the new value to the nav menu meta-boxes (the boxes to the left side of the page) this will do the job: The function … Read more
It looks like the above can be achieved with the walker_nav_menu_start_el filter (see reference). <?php function edit_menu_item($item_output, $item) { if ( get_field( ‘dropdown’, $item) == ‘yes’ ) { return ‘<button>’.$item->title.'</button>’; } return $item_output; } add_filter(‘walker_nav_menu_start_el’,’edit_menu_item’, 10, 2); Credit goes to @s_ha_dum via this answer.
I don’t think you need to initiate the menus again where register_nav_menus() itself is an initiator. Syntax: <?php register_nav_menu( ‘your-menu-handle’, ‘Your Menu Label’ ); ?> Copy the following code and Paste them into your functions.php without any function or add_action(), I hope it’ll work: register_nav_menus( array( ‘front_login_menu’ => __( ‘Front Login Menu location’), ‘top_front_general_menu’ => … Read more
menu entries are lost
Hook event for upload image in the menu