I have a navigation menu in WordPress. I would like it to check if the page has a custom field of “menu_icon” and if it does, add that custom field into the menu item it corresponds to. I’m sure this would require some sort of walker function extension but I am a bit new to PHP and WordPress. I’ve search around and have not found a suitable tutorial.
For example:
(normal menu)
<ul>
<li><a href="#">link</a></li>
</ul>
(custom)
<ul>
<li><span class="icon" style="background-image:url(CUSTOM FIELD CALLED HERE);"></span><a href="link">link</a></li>
</ul>
This is what i have used for checking to see if the custom field is there or not. I am sure you can use it as well.
It probably would look something like this with your code above:
You can use the get_post_meta function:
Read more about it here: http://codex.wordpress.org/Function_Reference/get_post_meta