Makes use of WP's built in 'Edit Links' to create and manage a website navigation menu that can be displayed using a custom template ta
Download
Contributors: acurran
Donate link: http://sww.co.nz/payments/
Tags: template tags, navigation, menu, nav menu, CMS, CMS enabling plugin, navigation links
Requires at least: 2.1
Tested up to: 2.8.4
Stable tag: 0.4
As well as being the leading blogging platform, WordPress is also one of the most flexible and easy to use general purpose content management systems for a wide variety of websites. However, one important CMS feature that is missing in the 'out of the box' installation of WordPress is a navigation menu management interface. A number of attempts have been made at plugins to address this need but most have been overly complex or cumbersome in some way so I have always coded my own navigation systems into my website templates.
After experimenting with a few different approaches for building navigation menus for a number of different websites, I discovered that WordPress actually does have an interface for managing navigation menus - well 'sorta'... I found that one good approach to creating navigation menus that could be easily managed by my clients is to use WordPress's built in links management interface. All it takes is a few lines of PHP code in the header template file to utilise the links navagation interface for the purpose of managing the website navigation menu. I have used this approach for building single level and multiple level navigation menus.
Now I have turned this approach to navigation menus into a simple plugin. This initial version adds the template tag 'show_nav()' which generates a single level navigation menu from the links contained in a 'nav' category. It is intended for use by users who create or edit their own templates. A multi-level version may follow.
ezy-nav-menu.php to the /wp-content/plugins/ directoryIf updating plugin please deactivate plugin and reactivate after uploading.
Usage:
In your theme template add the template tag 'show_nav()' at the point where you want the menu to appear (usually in the header template). This will generate the HTML output:
<div id="nav" class="nav">
<a href="{link web address}"
[title="{link description (if specified)}"]
[target="{link target (if specified)}"]
[class="current"(when link matches current page)]>[Link name]</a>
...
...
</div>
Note: for the class="current" to get added to link for current page, you need to have permalinks set so it is not using the default query string type links and you need to enter relative paths starting with / in your links (i.e. drop the http://mysitename.com part).
Additional Usage Options:
show_nav() takes 6 optional parameters:
show_nav($nav_id, $css_class, $before_html, $after_html, $seperator, $display_as_list)
$nav_id - change the id attribute on the outer container (default - 'nav')
$css_class - change the class attribute on the outer container (default - 'nav')
$before_html - add a HTML snippet in front of the link text
$after_html - add a HTML snippet after the link text
$seperator - seperator string placed between links
$display_as_list - boolean value; if set to true, outputs nav menu as unordered list (default - false)
e.g. the following line,
show_nav("nav", "nav", "<div>", "</div>", true);
would generate output such as the following:
<ul id="nav" class="nav">
<li><a href="link_url1"><div>Link Text 1</div></a></li>
<li><a href="link_url2" class="current"><div>Link Text 2</div></a></li>
...
...
</ul>
If you create or modify your template (theme) files and know a little CSS - Yes. If you've never opened a template file - maybe not this version, but soon I may do a version suitable for 'non-template' editing people too.
Version 0.4 (21 Aug 2009)
Updated so that class='current' gets added to nav link when on a child page as well as when on the page itself
Version 0.3 (13 Jul 2009)
Added option for seperator
Version 0.2 (23 Apr 2009)
Added before and after HTML snippet capability and the option to display menu as unordered list
Version 0.1
Initial release - single level navigation only
February 12th, 2009 at 7:19 am
[...] Ezy Nav Menu [...]
February 23rd, 2009 at 4:16 am
Hi, thanks for the great plugin and simple idea.
Would be nice though to have the ability to have multiple Links categories to be used with this plugin. Like a different menu for header nav, and footer nav, especially concerning the css. Also would be nice if the output is in list items.
Thanks again!
April 3rd, 2009 at 12:25 pm
The ability to use Wordpress categories as menu items and to have multi-level support would be nice as well.
April 28th, 2009 at 8:25 am
[...] Ezy Nav Menu [...]
May 7th, 2009 at 10:22 am
[...] Ezy Nav Menu [...]
May 18th, 2009 at 6:04 pm
I’m not following this.
When I place show_nav() in header all I get is show_nav() in the header on the front page.
May 18th, 2009 at 10:26 pm
What does this mean?
Generate “the following output” where? And once it’s generated, what are you supposed to do with it?
—————————————-
This will generate the HTML output:
[Link name]
…
…
—————————————–
May 19th, 2009 at 8:49 am
@riclad: have you got show_nav() inside < ?php ?> tags in your header template file? If it is there, it will either generate the output or generate an error (if the plugin is not activated).
May 19th, 2009 at 11:08 pm
The instructions say nothing about php tags.
I’ll try it, but shouldn’t the instructions say it, if it’s required?
May 20th, 2009 at 8:44 am
@riclad: in the description of the plugin: “… displayed using a custom template tag“
July 22nd, 2009 at 1:38 pm
Style the navigation menu in any way you want in the CSS using the style hooks provided (i.e. div#nav, div#nav a, div#nav a.current, div#nav a:hover, etc.).
Where are these style hooks provided? I have got the hooks above to work through trial and error but what are the rest? Am I just missing them somewhere or is this knowledge I should already have.
July 22nd, 2009 at 1:50 pm
The output HTML generated by the plugin is shown above so it’s just a matter of styling it with your css.
July 22nd, 2009 at 2:05 pm
Please note also the additional note I’ve added to the instructions regarding what is required for the plugin to add class=”current” to the link for the current page.
August 6th, 2009 at 8:46 pm
Great plugin, it is easy and handy, but I simply can’t get the class=”current” feature working… I’ve read through all the documentation several times, but I can’t find the added note that you mention. I’d hate having to write at PHP script to compare current page with link when obviously the feature is there, only I can’t shake it out from its’ vault…
I’m using
<?php show_nav("nav", "nav", "”, “”, true); ?>
August 6th, 2009 at 11:17 pm
@Leander – The note I mention is the paragraph above “Note: for the class=”current” to get added to link for current page, you need to have permalinks set so it is not using the default query string type links and you need to enter relative paths starting with / in your links (i.e. drop the http://mysitename.com part).”
This is the most likely reason it’s not working for you – you need to use relative URLs for it to work.
August 7th, 2009 at 2:24 am
Thank you for the quick reply. You were so right. It was the permalink issue. I’ve got it working now. However I’m using 0.2 of the plugin because the 0.3 renders an unexplicable “1″ between each menu item and breaks the “horisontalness” that I’ve styled for the menu. The 0.2 version works like a charm though… Thanks for a great plugin
August 21st, 2009 at 11:49 pm
Works great, thank you
August 24th, 2009 at 4:57 pm
nice plugin, i downloaded, will test it on my blog.
thank you
December 5th, 2009 at 8:03 pm
I love this plug in. Thank you. It works beautifully!
Any luck working out a multi-level version?
December 5th, 2009 at 9:18 pm
@Shelley – I have custom coded multi-level menus in the past using this technique but never got around to making it a releasable plugin. These days I tend to use wp_list_pages when I need multi-level menus.
February 8th, 2010 at 4:15 am
Hey, I’m using EZY Menu on a few sites now, but I can never get the ‘current’ class to appear on child pages too.
Is there a specific way to make this happen?
February 8th, 2010 at 4:20 am
Just to add that the EZY is on the navbar (as a parent or ancestor), to the child pages on a sidebar menu, using wp_list_pages, and ignoring the main parent.
February 8th, 2010 at 7:52 am
@Zohar: make sure the link url matches the slug and it is a relative url starting with /
February 15th, 2010 at 6:11 am
Is there a web site where I could see this plugin in action? Thanks!
February 15th, 2010 at 7:44 pm
@Tony: e.g. http://sawmilldirect.co.nz/, http://www.taxreturn.co.nz/