Custom Posttype and menu classes
Have you tried the Add Custom Post Types Achives to Nav Menus plugin? I just tested this locally and I get a current-menu-item class on both the archive page and also on the single post type.
Have you tried the Add Custom Post Types Achives to Nav Menus plugin? I just tested this locally and I get a current-menu-item class on both the archive page and also on the single post type.
I think, your question is similar to mine. I tried a similar thing earlier. Can check this StackOverflow thread started and answered by me.
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
Test: #menu current_page_ancestor a { opacity: 1.0; } Check this Menu Item CSS Classes
Try this. Goto Dashboard -> Appearance -> Menus -> screen options (See top corner) -> Check css classes -> Now add a custom class in your link ( Ex: lightboxlink ) Now add some jquery code in the footer like $(document).ready(function() { $(“.lightboxlink”).click(function() { lightbox(); }); });
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
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; }
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”; } }
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 }
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