How to add a menu that belongs to parent blog to all child-blogs?

Well, thanks to @toscho … For your help I found a way to achieve show the primary nav that belongs to parent blog to all child blogs: /** * Plugin Name: Network Primary Nav * Network: true */ add_filter( ‘wp_nav_menu_objects’, ‘network_primary_nav’, 100, 2 ); function network_primary_nav( $menu_items, $args ) { global $blog_id; $menu_name=”primary”; if ( … Read more

Removing Submenu from Menu

You can change nav menu args via the wp_nav_menu_args filter. So let’s say you have a theme that does something like this… <?php wp_nav_menu(array( ‘theme_location’ => ‘second_level’, ‘depth’ => 2, // how many levels to show // prolly some other stuff here )); You can hook into wp_nav_menu_args, check for the theme location, and set … Read more

Search form as list item in menu?

You can add any item you want to a menu by filtering wp_nav_menu_items. From the tutorial How to Add a Search to Menu, this is how you’d add a search form: add_filter(‘wp_nav_menu_items’,’add_search_box’, 10, 2); function add_search_box($items, $args) { $searchform = get_search_form( false ); $items .= ‘<li>’ . $searchform . ‘</li>’; return $items; }

Costum walker with sub menu item count

Inside the function your $x is local. You might want to use a static variable: class Walker_Nav_Menu_Costum extends Walker_Nav_Menu { static $x = 0; function end_el( &$output, $item, $depth = 0, $args = array() ) { if ( 1 == $depth ) self::$x++; $output .= “<!– x:”.self::$x.”–>”; $output .= “</li>\n”; } }

How to get current pages menu text?

You can get a Menu’s entire item list with wp_get_nav_menu_items(). Then, loop through them all and test against the current post_id, and voila, you have all your data. <?php $menu_items = wp_get_nav_menu_items( ‘main-menu’ ); foreach( $menu_items as $item ) { print_r( $item ) ; // see what you can work with // carry on }

How to add active class to separate page link?

Not the cleanest solution, but I use something like this for a few instances of current page menu highlighting for pages that aren’t child/parent related in any way: <?php if (is_page(‘tutorials-by-topic’) { ?> <script type=”text/javascript”> jQuery(function($) { $(document).ready(function() { $(‘#menu-main-menu li.menu-item-1319’).addClass(‘current-menu-item’); }); }); </script> <?php } ?> You have to look at the source to … Read more