Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Adding Custom Attribute To Menu Item to open modal #190

Closed
ineptian opened this issue Jan 15, 2015 · 4 comments
Closed

Adding Custom Attribute To Menu Item to open modal #190

ineptian opened this issue Jan 15, 2015 · 4 comments

Comments

@ineptian
Copy link

Hi and thanks for providing such a great theme. I am struggling to understand how I would add a custom attribute to a menu item in wordpress so that when I click contact in my menu, it opens a modal instead of going to a page. I think the answer lies here somewhere: http://codex.wordpress.org/Plugin_API/Filter_Reference/nav_menu_link_attributes but I can't figure out how to implement it. Any help would be much appreciated. Specifically where should these different chunks of code go, and what do I need to edit for it to work with the foundationpress top bar?

Thanks!

@themestechnology
Copy link
Contributor

You will get better support for this on the Wordpress forum as this a core
WP function.

Looking at the demo I can see that each li in the menu already and an
identifier "menu-item-xx" is this not enough to do what you need?

http://foundationpress.olefredrik.com/kitchen-sink/

https://wordpress.org/support/

@ineptian
Copy link
Author

I'm trying to assign, data-reveal-id="myModal" to a menu item in wordpress. This is built in in foundation, but unfortunately adding custom attributes to menu items isnt in wordpress. I would have guessed that someone on here already ran into this problem and had a solution but after searching I couldn't find anything.

@themestechnology
Copy link
Contributor

This is a bit beyond me but I would suggest extending the WP Menu function...

http://jamescollings.co.uk/blog/wordpress-custom-walker-output-section-of-menu/

@linuxbastard
Copy link
Contributor

You would need to modify the menu walker to add classes and extra attr, so I would start there. (library\menu-walker.php)

If you want to be able to change what you add you can start with a plugin that adds custom attributes to the menu items and then call it from the menu walker. I found these articles that may help:

http://wordpress.stackexchange.com/questions/103345/wp-nav-menu-add-attributes-to-menu-items
http://www.wpexplorer.com/adding-custom-attributes-to-wordpress-menus/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants