Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter haufrs1

    (@haufrs1)

    Hi Tom,

    Sorry about the confusion. Your recommendation worked and we’re able to add the ID’s to the actual anchor tag. Thank you!

    Thread Starter haufrs1

    (@haufrs1)

    Hi Tom,

    We’ve tried this on our staging site and weren’t able to get any id’s to appear on the <a> itself.

    function add_id_to_menu_items( $atts, $item, $args ) {
      // Set the ID attribute to the value of the menu item’s title.  if(!empty($item->title))
        $atts[‘id’] = $item->title;

      return $atts;
    }

    add_filter( ‘nav_menu_link_attributes’, ‘add_id_to_menu_items’, 10, 3 );

Viewing 2 replies - 1 through 2 (of 2 total)