Last active
August 5, 2019 19:45
-
-
Save farik92/c0a50d532a92ab64a8e0ee5709387c2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Удаляем ссылку у текущего пункта меню WordPress | |
| function wp_nav_menu_no_current_link( $atts, $item, $args, $depth ) { | |
| if ( $item->current ) $atts['href'] = ''; | |
| return $atts; | |
| } | |
| add_action( 'nav_menu_link_attributes', 'wp_nav_menu_no_current_link', 10, 4 ); | |
| //Если есть необходимость применить это только для конкретного меню, то код будет таким: | |
| function wp_nav_menu_no_current_link( $atts, $item, $args, $depth ) { | |
| if ( $args->theme_location == 'menu_name' ) { | |
| if ( $item->current ) $atts['href'] = ''; | |
| } | |
| return $atts; | |
| } | |
| add_action( 'nav_menu_link_attributes', 'wp_nav_menu_no_current_link', 10, 4 ); | |
| //Здесь menu_name — это идентификатор, который указывается в функции register_nav_menu() и в параметре theme_location функции wp_nav_menu(). | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment