Add the current menu item CSS class to a custom page type archive in WordPress menu

This is what you want to do, add_filter( ‘wp_get_nav_menu_items’, ‘cpt_archive_menu_filter’, 10, 3 ); function cpt_archive_menu_filter( $items, $menu, $args ) { foreach ( $items as &$item ) { if ( $item->type != ‘custom’ ) continue; if ( get_query_var( ‘post_type’ ) == ‘your-post-type’ && $item->title == ‘Title of Link’ ) { $item->classes []= ‘class-name-your-want’; } } return … Read more

Vertical Sidebar Menu Parent and Child not displaying correctly [closed]

Add this to your function.php file: function hierarchical_submenu_get_children($post, $current_page) { $menu = null; // Get all immediate children of this page $children = get_pages(‘child_of=” . $post->ID . “&parent=” . $post->ID . “&sort_column=menu_order&sort_order=ASC’); if ($children) { $menu = “\n<ul>\n”; foreach ($children as $child) { // If the child is the viewed page or one of its … Read more

Nav Walker current menu item not displaying

Since it is working as you expect in the header.php file (but not in sidebar.php), you could add this into header.php: global $my_nav; $my_nav= wp_nav_menu( array( ‘menu’ => ‘main-menu’, ‘container’ => ”, ‘container_class’ => ‘navbar-blue’, ‘menu_class’ => ‘nav’, ‘menu_id’ => ‘main-menu’, ‘walker’ => new Bootstrapwp_Walker_Nav_Menu(), ‘echo’ => 0, ) ); ?> and then in your … Read more

selected menu item

I definetly suggest you to use WordPress menu feature, is quite easier to implement and you will never need to wory if the user want to rename or add new items. Just add this to your functions.php: register_nav_menus( array( ‘main_menu’ => ‘Main menu’, ) ); Then in header.php or wherever you have the menu add: … Read more

How to add a CSS class to the tooltip on a navigation menu?

Add this code into your functions.php class Tooltips_Walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { $classes = empty ( $item->classes ) ? array () : (array) $item->classes; $class_names = join( ‘ ‘ , apply_filters( ‘nav_menu_css_class’ , array_filter( $classes ), $item ) ); ! empty ( $class_names ) and $class_names=” class=””. esc_attr( $class_names ) … Read more

WordPress Split Menu

You can do this via css by pushing the first element of the second menu over, and then position:absolute your logo e.g. (not tested) #element li:nth-child(4) { margin-left:300px; } #logo { position:absolute; left:500px top:50px; } Change the pixels to your desired lengths This can also be done with jQuery append e.g. $( “#element li:nth-child(3)” ).append( … Read more

Create self-populating menu and add extra divs to the menu layout

Your html structure should look like <ul class=”parent-class”> <li>Page 1</li> <li> <ul class=”child-class”> <li> Sub menu item 1</li> <li> Sub menu item 2</li> </ul> </li> </ul> WordPress should automatically add an “active” class to the active page then you should be able to style everything with css. Something like .parent-class li ul { Display:none; } … Read more