Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using Foundation as a base and starter theme. I'm trying to build and I can't seem to figure out how to hook into the menu that WordPress outputs and add a custom attribute to that menu's <li> tags.

The current menu outputs like this:

<ul id="menu-main-menu-1" class="top-bar-menu right">
<li class="divider"></li>
<li class="menu-item "><a href="#home">Home</a></li>
<li class="divider"></li>
<li class="menu-item"><a href="#about">About</a></li>
<li class="divider"></li>
<li class="menu-item"><a href="#work">My Work</a></li>
<li class="divider"></li>
<li class="menu-item"><a href="#contact">Contact</a></li>

(Those links are just there for sample)

I need WordPress to automatically add the following attribute to the <li> tags: data-magellan-arrival="[target]".

[Target] needs to automatically be populated by the page_ID that the menu item corresponds to. So for example, let's say that first's <li><a href="">[PAGE]</a></li> link is Home and Home's page_ID is "21" (example). I would need data-magellan-arrival="[target]" inside of <li> to be set to data-magellan-arrival="21".

So it would look like: <li class="menu-item" data-magellan-arrival="21"><a href="">[PAGE]</a></li>

I'll be honest with you, I'm not that great at PHP just yet and WordPress filters/hooks much less. Hoping someone can point me in the right direction or show me how to do it.

share|improve this question

1 Answer 1

This looks like this would get you pointed in the right direction.

share|improve this answer
Answers should not rely on external links. This is rather a comment than an answer. Please file an edit and post the relevant info inside your answer, keeping the link as reference only –  Pieter Goosen Dec 19 '14 at 6:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.