Support » Fixing WordPress » Add custom ID to final li in wp_nav_menu

  • Hello all,

    I’m using three primary navs in my theme and I’m attempting to place a final link to the menu with a custom ID across all primary navs.

    This is what I’m going for:

    <nav id="menu" role="navigation" class="menu-primary">
    <ul id="nav" class="menu">
    <li id="menu-item-418" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-418"><a href="#">About</a></li>
    <li id="menu-item-474" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-474"><a href="#">Work</a></li>
    <li id="menu-item-463" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-463"><a href="#">Blog</a></li>
    <li id="menu-item-416" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-416"><a href="#">Contact</a></li>
    <li id="back" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-491"><href="#header">back</a></li>

    As you can see, the final li has an ID of ‘back’. Any idea how I can accomplish this without the use of js? I can see how I can change classes, but not ID’s. I’m doing this for CSS purposes.

    Any help will be greatly appreciated!

    [No bumping, thank you.]

  • The topic ‘Add custom ID to final li in wp_nav_menu’ is closed to new replies.