carlosmdh

Añadir clase a los elementos del menú en WordPress

Apr 27th, 2022
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. /* Añadir clase a los elementos del menu */
  2.  
  3. function cmdh_add_specific_menu_location_atts( $atts, $item, $args ) {
  4.     // check if the item is in the primary menu
  5.     if( $args->theme_location == 'primary' ) {
  6.       // add the desired attributes:
  7.       $atts['class'] = 'carlosmdh-menu-link-class';
  8.     }
  9.     return $atts;
  10. }
  11. add_filter( 'nav_menu_link_attributes', 'cmdh_add_specific_menu_location_atts', 10, 3 );
  12.  
  13.  
Advertisement
Add Comment
Please, Sign In to add comment