Last active
September 1, 2019 04:44
-
-
Save Asikur22/a3063730bb388d1a16e44c4764755904 to your computer and use it in GitHub Desktop.
[Add CSS Class to Last Menu Item] #WordPress #AnchorTag
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 CSS Class to Last Menu Item Anchor Tag | |
*/ | |
function add_specific_menu_atts( $atts, $item, $args ) { | |
if ( $args->menu->count == $item->menu_order && $args->theme_location == 'primary' ) { | |
$atts[ 'class' ] = 'btn-def'; | |
} | |
return $atts; | |
} | |
add_filter( 'nav_menu_link_attributes', 'add_specific_menu_atts', 10, 3 ); |
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 CSS Class Menu Item Anchor Tag | |
*/ | |
function add_specific_menu_atts( $atts, $item, $args ) { | |
if ( $args->theme_location == 'primary' ) { | |
$atts[ 'class' ] = 'btn-def'; | |
} | |
return $atts; | |
} | |
add_filter( 'nav_menu_link_attributes', 'add_specific_menu_atts', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment