Created
December 27, 2018 06:47
-
-
Save dasbairagya/0a8cd5a49fd184eae001a318349f4571 to your computer and use it in GitHub Desktop.
overwrite nav-menu attribute
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
add_filter( 'nav_menu_link_attributes', function ( $atts, $item, $args ) { | |
if ( 802 === $item->ID ) { // change 1161 to the ID of your menu item. | |
if(is_front_page() || is_home()){ | |
$atts['href'] = '#dine-in-menu'; | |
$atts['target'] = ''; | |
} | |
else{ | |
$atts['href'] = home_url('/#dine-in-menu'); | |
$atts['target'] = ''; | |
} | |
} | |
if(998 === $item->ID ){ | |
$atts['target'] = '_blank'; | |
} | |
if(91 === $item->ID){ | |
$atts['style'] = 'padding-right:30px'; | |
} | |
if ( 801 === $item->ID ) { // change 1161 to the ID of your menu item. | |
if(is_front_page() || is_home()){ | |
$atts['href'] = '#lunch'; | |
$atts['target'] = ''; | |
} | |
else{ | |
$atts['href'] = home_url('/#lunch'); | |
$atts['target'] = ''; | |
} | |
} | |
return $atts; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment