Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function my_special_nav_class( $classes, $item ) {
- if ( is_single() && $item->title == 'Blog' ) {
- $classes[] = 'special-class';
- }
- return $classes;
- }
- add_filter( 'nav_menu_css_class', 'my_special_nav_class', 10, 2 );
- <?php
- $args = array(
- 'order' => 'ASC',
- 'orderby' => 'menu_order',
- 'post_type' => 'nav_menu_item',
- 'post_status' => 'publish',
- 'output' => ARRAY_A,
- 'output_key' => 'menu_order',
- 'nopaging' => true,
- 'update_post_term_cache' => false );
- $items = wp_get_nav_menu_items( 'my manu', $args );
- $page_url = get_permalink();
- foreach($items as $item ) :
- ?>
- <li <?php if($item->url == $page_url){?>class="active"<?php }?>><a href="<?php echo $item->url;?>"><?php echo $item->title;?></a></li>
- <?php endforeach;?>
- <!-----------------------------Dynamic manu end---------------------------------------------------->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement