• Hey everyone, I have been working pretty hard in order to turn my wordpress website into a PWA and things are looking fairly good.I am struggling at the moment with one thing which is to do with ID attributes not being unique. I think its got something to do with the Desktop/Mobile menu but I am not 100% sure about that. Has anyone run into this before and may be able to offer some pointers? Much appreciated.

    [id] attributes on the page are not unique
    The value of an id attribute must be unique to prevent other instances from being overlooked by assistive technologies. Learn more.
    View failing elements
    <li id=”menu-item-62″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-home current-menu-item page_item page-item-48 current_page_item menu-item-62″>
    <li id=”menu-item-1121″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-1121″>
    <li id=”menu-item-1241″ class=”menu-item menu-item-type-post_type menu-item-object-post menu-item-1241″>
    <li id=”menu-item-63″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-63″>
    <li id=”menu-item-1691″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-1691″>
    <li id=”menu-item-1986″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-1986″>
    <li id=”menu-item-66″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-66″>
    <li id=”menu-item-67″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-67″>

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Yes, if there are more than one nav menu on a page and each menu contains the same menu item, redundant IDs will occur. The true solution would involve using a modified walker that generates IDs based on a unique value instead of only using “menu-item-“.

    An easier approach would be to hook “wp_nav_menu” filter and grab the menu name out of the arguments, then use it to replace or augment occurrences of “menu-item”. If there is no menu name argument, it’s for the default menu and nothing further needs to be done.

    Thread Starter sdawales

    (@sdawales)

    Thanks @bcworkz. Appreciate it and we’ll give it a go. Cheers.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘ID Attributes are not Unique’ is closed to new replies.