Created
August 11, 2019 08:04
-
-
Save RiodeJaneiroo/44ddc2a03f3abd2b42e0fd8d194d9b2e to your computer and use it in GitHub Desktop.
[Удалить ссылку на саму себя из меню] #wordpress #seo
This file contains 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 | |
function yourstheme_menu_link_attributes( $args ) { | |
global $wp; | |
$current_url = untrailingslashit(add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) ) ); | |
$href = untrailingslashit( $args['href']); | |
if($current_url == $href){ | |
$args['href'] = ''; | |
} | |
return $args; | |
} | |
add_filter( 'nav_menu_link_attributes', 'yourstheme_menu_link_attributes' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment