Knowledgebase Docs » UberMenu 3
UberMenu 3

The ubermenu_anchor_attributes filter allows you to control the attributes on the anchor of any menu item.


This example adds the attribute data-my-att with the value my-value to menu item 99, which would result in an anchor like this

<a href="http://mysite.com/about" data-my-att="my-value">About</a>

Example filter code:

add_filter( 'ubermenu_anchor_attributes' , 'um_modify_anchor_atts' , 10 , 5 );
function um_modify_anchor_atts( $atts , $menu_item_type , $menu_item_id , $object_type , $object_id ){

   //Target menu item 99
   if( $menu_item_id == 99 ){

      //Set a special attribute for this item's anchor
      $atts['data-my-att'] = 'my-value';

   return $atts;

It is critical to always return the $atts array


Your registered callback will be called once for each item in the menu. Each key in the returned array will become an attribute in the anchor with its associated value.

This is an array of anchor attributes in key/value pairs. Careful not to override existing attributes!
The type of menu item in Appearance > Menus.
This is the numeric ID of the menu item. Use this to target items individually.
The type of object that the menu item points to.
The ID of the object that the menu item points to.