Skip to content

Instantly share code, notes, and snippets.

@RiodeJaneiroo
Created August 11, 2019 08:04
Show Gist options
  • Save RiodeJaneiroo/44ddc2a03f3abd2b42e0fd8d194d9b2e to your computer and use it in GitHub Desktop.
Save RiodeJaneiroo/44ddc2a03f3abd2b42e0fd8d194d9b2e to your computer and use it in GitHub Desktop.
[Удалить ссылку на саму себя из меню] #wordpress #seo
<?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