Output sort number in wp menu list item?
As I edited above, I found the answer myself. Just use: $item->menu_order
As I edited above, I found the answer myself. Just use: $item->menu_order
I checked out the walk method from the original Walker class source at WordPress and used that to get my result. I added a couple of more things to it, including: Adding first and last classes to the every ul in the navigational menu. Adding odd and even classes to every li relative to the … Read more
Yes it is possible, please take a look at the code below it will give you the basic idea. You can change ul to div and add some logic to match your needs. $menu_name=”primary”; $menu = wp_get_nav_menu_object( $locations[ $menu_name ] ); $menu_items = wp_get_nav_menu_items($menu->term_id); $menu_list=”<ul id=”menu-” . $menu_name . ‘”>’; foreach ( (array) $menu_items as … Read more
Conditional Nav Menu Inside Nav Menu Across Multisite Sites
You have a script active that prevents normal behaviour of links if they have no target=”_blank” attribute on them. The original site has this attribute on the link to the blog, so that one works. The ‘new’ site doesn’t have it on the menu links, so those links are disabled. To fix this, go to … Read more
If you need to add different classes for the tag, consider using jQuery .addClass() for it or javascript solution if you don’t want to use jQuery. Your other options are to try and fit the parameters which wp_nav can use. $args (array) (Optional) Array of nav menu arguments. ‘menu’ (string) Desired menu. Accepts (matching in … Read more
This code will check to ensure that the theme_location is header. Also, menu is the parameter where the desired WordPress Nav menu is specified. menu_id is the HTML ID that is applied to the <ul> element which forms the menu. Docs on the arguments for wp_nav_menu() can be found here. add_filter( ‘wp_nav_menu_args’, ‘bb_wp_nav_menu_args’ ); function … Read more
You’ve got the code close, but incorrect. It is a spelling issue. It should be: <?php wp_nav_menu(array(‘theme_location’=>’primary’)); ?> <?php wp_nav_menu(array(‘theme_location’=>’secondary’)); ?> Please note that in your array you are using the_location and not theme_location. I believe with your mistake the menu will default to the primary menu (though I haven’t confirmed this).
Add Class to Custom Menu Widget ul
try this code in your functions file. function add_class_to_nav_items($nav_items, $args) { if ( $args[‘theme_location’] == ‘MY_NAV_THEME_LOCATION’ ) { // IMPORTANT: replace MY_NAV_THEME_LOCATION with the location of your menu foreach ($nav_items as &$nav_item) { $nav_item->classes[] = ‘custon-class-name’; } } return $nav_items; } add_filter( ‘wp_nav_menu_objects’, ‘add_class_to_nav_items’, 11 );