Assign different category colours to different categories in the main menu

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

Nav Menu and display post count

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

Replace menu tag with tag

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.

Custom menus created but does not show up in admin panel

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

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