How to add custom menu to block theme?
How to add custom menu to block theme?
How to add custom menu to block theme?
You can retrieve nav menu locations with get_nav_menu_locations int[] Associative array of registered navigation menu IDs keyed by their location name. If none are registered, an empty array. https://developer.wordpress.org/reference/functions/get_nav_menu_locations/ This refers to a theme mod internally named nav_menu_locations which can be used to update the locations. You can modify that returned value and then save … Read more
How about just go to the menu from wp-admin remove product menu(i.e the current one) now create a new menu (Product)using Custom Menu and put url to # and add ur sub menus, if u have different class for current menu u can add custom class too follow these steps In Appearance > Menus, click … Read more
An entirely different approach. nav menu item are stored in posts table, so you can technically attach a post_meta into it, even other data like nav item class already stored in post mata table. However this wasn’t easy to do before. but after 5.4.0 release, they have implemented hooks to easily do this. Here’s the … Read more
getMenu() fetches data from the GET /wp/v2/menus/<id> endpoint, whereas getMenuItem() fetches data from the GET /wp/v2/menu-items/<id> endpoint, but they have the same usage syntax, where you just need to pass the ID of a menu or menu item. As for getMenuItems() and another function you can use — getMenus(), the endpoints are GET /wp/v2/menu-items (for … Read more
Seems like you’re using a parent theme or a plugin that registers those menu locations. If that’s the case then you shouldn’t remove your last function. You need to keep the remove_default_menu function in your functions file. If you are not using a parent theme or some sort of plugin than that means you are … Read more
Am I using this hook incorrectly No, you’re not. is there another way to get the ID? Yes, try this: function add_menu_field( $item_id, $item, $depth, $args, $id ) { $id2 = 0; if ( ! $id && isset( $_GET[‘menu’] ) && $_GET[‘menu’] ) { $id2 = absint( $_GET[‘menu’] ); } elseif ( ! $id && … Read more
Update: I found a way to do this, though not by using wp_nav_menu. Instead, I re-invoked wp_list_bookmarks; and used this code: wp_list_bookmarks(‘orderby=rand’);
Possibly yes, possibly no. I would recommend setting them to private and published so that you can see links working. Drafts cannot be selected as menu links, nor do they have permalinks until they’re published (only the shortlinks and only while logged in), so that is why they aren’t working. If you’re afraid of taking … Read more
Is there any way to enable the Appearance->Menus in the admin dashboard while FSE theme is enabled I noticed that in some FSE themes the classic Menus admin page shows up under Appearance: when they include a register_nav_menus( … ) call within the after_setup_theme hook to define the relevant classic menu locations. See for example … Read more