Skip to content

Instantly share code, notes, and snippets.

@dasbairagya
Created December 27, 2018 06:47
Show Gist options
  • Save dasbairagya/0a8cd5a49fd184eae001a318349f4571 to your computer and use it in GitHub Desktop.
Save dasbairagya/0a8cd5a49fd184eae001a318349f4571 to your computer and use it in GitHub Desktop.
overwrite nav-menu attribute
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