Custom Post type menu highlighted in the archive/post

You have it almost right. Try the following: function add_active_classes($classes = array(), $menu_item = false){ global $wp_query; if(in_array(‘current-menu-item’, $menu_item->classes)){ $classes[] = ‘current-menu-item’; } if ( $menu_item->title == ‘product’ && is_post_type_archive(‘product’) ) { $classes[] = ‘current-menu-item’; } if ( $menu_item->title== ‘product’ && is_singular(‘product’) ) { $classes[] = ‘current-menu-item’; } return $classes; } add_filter( ‘nav_menu_css_class’, ‘add_active_classes’, 10, … Read more

wp_nav_menu show 1 item only

Why would you only want to display one item from a menu of many items? You can create additional menus by registering them in your functions.php file and then associating then in the Appearance -> Menus area of the WP-Admin. http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus

Output menu navigation in php file

You would require the path to wp-blog-header.php to access WordPress functionality in a standalone PHP file. So your justthemenu.php file should contain the following code. <?php require(‘/wp-blog-header.php’); wp_nav_menu( array( ‘container_class’ => ‘menu-header’, ‘theme_location’ => ‘primary’ ) ); ?>

wp_nav_menu – show children of current menu item only?

Don’t know if this is the best way but i would go like this- 1) Hook into wp_nav_menu_objects filter. The function will recieve a list of all menu-items. These menu items will already have the information regarding current page or current page’s ancestor(do a var_dump once) 2) From these menu items, unset all the menu … Read more

WordPress Custom Menu Widget Style

Purely with CSS you could set a width for menu items, float them and then set the UL to twice that: footer ul { width: 200px; } footer .menu-item { float: left; width: 100px } (I don’t know what elements you are using to designate your footer, you’ll need to update that to match your … Read more

how to get nav menu list through menu name in wordpress

I think you’re looking for the wp_nav_menu() function, which deals with the navigation menus that you create in the WordPress admin (Appearance > Menus) You can call it like this: <?php wp_nav_menu( array( ‘menu’ => ‘Header Menu’ ) ); ?> Where Header Menu is the name of the menu you want to print. There are … Read more

Add class to active element and its parent in nav menu

Depending on the context you need this and working off of the code you have, you can try this: add_filter(‘nav_menu_css_class’, ‘add_active_class’, 10, 2 ); function add_active_class($classes, $item) { $class_names = array( ‘current-menu-item’, ‘current-menu-ancestor’, ‘current-menu-parent’, ‘current_page_parent’, ‘current_page_ancestor’ ); if( $item->menu_item_parent == 0 && in_array( $class_names, $classes) ) { $classes[] = “active”; } return $classes; } UPDATE: … Read more