Add class to menu ul with active child
You certainly could build a custom walker, but perhaps the easiest way out is jquery: $(“li.active”).parent().addClass(“is-active”);
You certainly could build a custom walker, but perhaps the easiest way out is jquery: $(“li.active”).parent().addClass(“is-active”);
You can use something like this, add_filter( ‘wp_nav_menu_items’, ‘your_custom_menu_item’, 10, 2 ); function your_custom_menu_item ( $items, $args ) { if ( $args->theme_location == ‘Primary’ ) { // change the menu location if not Primary $items .= ‘<a class=”request-maintenance-open” href=”#contact_form_pop”>Request Maintenance</a>’; } return $items; }
You were really close. There is container argument for wp_nav_menu: ‘container’ (string) Whether to wrap the ul, and what to wrap it with. Default ‘div’. Its default value is ‘div’, which means, that the ul will be wrapped with div tag. You can change it to false – ul won’t get wrapped at all in … Read more
Ideally, you should be passing the “theme_location” argument to wp_nav_menu(). Register your three menus in functions.php: register_nav_menus( array( ‘front_page’ => ‘Front Page Menu’, ‘single’ => ‘Single Post Menu’, ‘default’ => ‘Default Menu’ ) ); Then, replace your code above with: if ( is_front_page() ) { wp_nav_menu( array( ‘container_class’ => ‘menu-header’, ‘theme_location’ => ‘front_page’ )); } … Read more
You need to first collect the menu locations, then set the primary menu location with the menu id. // Set the menu to primary menu location $locations = get_theme_mod( ‘nav_menu_locations’ ); $locations[‘primary’] = $primary_nav_menu_id; set_theme_mod ( ‘nav_menu_locations’, $locations ); Here I assume ‘primary’ is theme location referring to ‘Primary Navigation’.
Changing the CSS is the simplest way to apply your desired styles. Another alternative, as Jack mentioned, is to create a custom walker. The Codex has a good overview. The third option is a happy medium – you can customize the menu partially just with your wp_nav_menu() call. For example, this call wp_nav_menu(array( ‘menu’ => … Read more
Filters (and actions) need to be declared with the number of arguments accepted by the callback; it is the fourth parameter of add_filter() (default 1): add_filter( ‘nav_menu_item_args’, ‘filter_nav_menu_item_args’, 10, 3 ); function filter_nav_menu_item_args( $args, $item, $depth ) { print_r( $item ); return $args; } See add_filter() for reference.
Create a custom menu item in the admin panel with a dummy URL, foo.com or whatever. Add it to the menu, then delete the target URL and save. The menu item will be rendered without an href attribute and will be unclickable.
have you ticked the ‘Description’ box under ‘Show advanced menu properties’ in the ‘screen options’ tab in the appearance -> menus page? and have a look at this related post: http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output
It is possible. Two options: If the subpages are just children of the currently displayed page, you call: wp_list_pages( array ( ‘child_of’ => $GLOBALS[‘post’]->ID ) ); See Codex documentation. Very simple. If you need a custom structure, for example a list of custom taxonomies when a special post type is viewed, you need to create … Read more