WP Menubar documentation
[Updated October 15, 2010]
Menubar is a WordPress menu plugin that adds one or more configurable menus to your WordPress site. With Menubar you can create both single and multi-level menus, and you can style them with customizable menu templates.
This page contains the updated documentation for Menubar 4.9.
Contents
- Requirements
- Features
- Upgrading procedure
- First installation procedure
- Create your menus
- Configure your menus
- Menubar templates
Requirements
1) Menubar requires WordPress 2.6 or higher.
2) Your theme must include a call to the wp_head() function. Usually this call is made in the header.php file, right before the </head> line. If your theme doesn’t include a call to wp_head(), you should add it yourself, otherwise you’ll get an error like this:
WP Menubar error: Function wpm_display_Suckerfish() not found!
[back to Contents]
Features
With WordPress Menubar:
* you can build fully customized single or multi-level menus with the homepage, the frontpage, categories, category trees, static pages, page trees, tag archives, single posts, a search box, and any static or PHP generated URLs; the currently selected menu item is dynamically highlighted, but you can disable this feature if you don’t like it;
* you can add, edit and delete menus and menu items in an easy to use administration panel, which blends nicely with the existing WordPress administration panels;
* you can specify where to place each menu by inserting in your theme a short line of PHP code; you can also use the included Menubar widget to place a menu in a sidebar or widget-ready area of your theme (only with WordPress 2.8 or higher);
* you can choose one of the available menu templates to style each menu, and you can modify or rewrite the menu templates as you like; the automatic plugin upgrades won’t overwrite your customizations;
* if you deactivate the plugin your menus will disappear, and if you reactivate the plugin your menus will reappear unchanged.
[back to Contents]
Upgrading procedure
Case 1
If you are upgrading to the current version from Menubar 3.1 or higher:
a) From the Plugins administration panel, deactivate the old Menubar version;
b) Delete the menubar folder in wp-content/plugins;
c) Download the plugin archive from the WordPress Plugin Directory and unzip it, then upload the resulting menubar folder with all its contents to wp-content/plugins;
d) From the Plugins administration panel, activate the new Menubar version.
These are the same steps performed by the automatic upgrade procedure, so you can safely run the automatic upgrade. In both cases, all your template customizations won’t be affected.
Case 2
If you are upgrading to the current version from Menubar 3.0:
a) Create a new folder named menubar-templates under wp-content/plugins;
b) Move the Basic and Suckerfish folders with all their contents from wp-content/plugins/menubar to wp-content/plugins/menubar-templates; do the same for all the other Menubar templates you have installed;
c) From the Plugins administration panel, deactivate the old Menubar version;
d) Delete the menubar folder in wp-content/plugins;
e) Download the plugin archive from the WordPress Plugin Directory and unzip it, then upload the resulting menubar folder with all its contents to wp-content/plugins;
f) From the Plugins administration panel, activate the new Menubar version.
Steps c) through f) are the same steps performed by the automatic upgrade procedure, so you could manually perform the steps a) and b), and then run the automatic upgrade.
Case 3
If you are upgrading from Menubar version 1.x or 2.x, just delete the menubar folder in wp-content/plugins, and perform a first installation procedure of the current Menubar version. Please note that menus built with Menubar version 1.x or 2.x will be lost in the upgrade to newer Menubar versions.
[back to Contents]
First installation procedure
To install the current Menubar version for the first time:
a) Download the plugin archive from the WordPress Plugin Directory and unzip it, then upload the resulting menubar folder with all its contents to wp-content/plugins;
b) From the Plugins administration panel, activate the current Menubar version;
c) From the Appearance administration panel you can now access the new Menubar sub-panel.
Steps a) and b) are the same steps performed by the automatic install procedure, so you can safely run the automatic install. In both cases, before using Menubar, you’ll have to:
d) Create a new folder named menubar-templates under wp-content/plugins;
e) Install one or more Menubar templates, at least Suckerfish (see Menubar templates).
Now you can create your first menu (see next section).
[back to Contents]
Create your menus
From the Appearance – Menubar administration panel you can create, edit, and delete menus. Menus are specified with the following fields:
* Name: the name of your menu; will be used to insert the menu in your theme.
* Template: the Menubar template and the stylesheet you wish to apply to this menu. You can also choose to apply a template without a stylesheet, and in this case you’ll have to provide your own CSS rules, e.g. in your theme style.css file. Please note that not all Menubar templates support multi-level menus.
Important: edit your theme inserting the following line of code where you wish to display your menu. If your menu name is mymenu, the line of code to insert in your theme is:
<?php do_action('wp_menubar','mymenu'); ?>
A good starting place to insert the above line of code could be at the end of the header.php file.
Another way to integrate your menu in your theme is to use the included Menubar widget, which allows you to add a menu in a sidebar or widget-ready area of your theme (only with WordPress 2.8 or higher).
Before looking at your new menu, please add at least one menu item (see next section).
[back to Contents]
Configure your menus
From the Appearance – Menubar administration panel you can add, edit, and delete menu items for each of your menus. Menu items are specified with the following fields:
* Order: indicates where this menu item will be placed. Choices are:
- Before…: this item will be placed right before the item you select.
- Child of…: this item will be placed as a sub-item of the item you select; please note that to display a multi-level menu you’ll need a multi-level Menubar template like Suckerfish.
- After…: this item will be placed right after the item you select.
You can later modify the ordering of your menu items using the Edit command or the up and down arrows in the menu items list.
* Name: specifies the name of this menu item as shown in the menu; for instance Home, About, News, Gallery, and so on.
* Type: specifies the menu item type. Each type may require additional fields, as shown below:
- type Home: this menu item points to your main blog page (the latest posts list).
- type FrontPage: this menu item points to your static front page, if configured in WordPress Settings – Reading, otherwise it’s the same as Home.
- type Heading: this menu item is non clickable, and could be used in a multi-level menu as the parent of a set of sub-items.
- type Tag: this menu item points to the tag archive specified in the Tag field.
- type TagList: this menu item generates a menu sub-item for each tag archive, excluding the tags specified in the Exclude field. Please note that, if you add sub-items to a TagList item, they will be ignored and won’t be displayed in your live menu.
- type Category: this menu item points to the category archive specified in the Category field.
- type CategoryTree: this menu item points to the category archive specified in the Category field, and automatically generates a menu sub-item for each sub-category, excluding the categories specified in the Exclude field, and up to the level specified in the Depth field. Any categories selected in the Headings field will be made non clickable. Please note that, if you add sub-items to a CategoryTree item, they will be ignored and won’t be displayed in your live menu.
- type Page: this menu item points to the static page specified in the Page field.
- type PageTree: this menu item points to the static page specified in the Page field, and automatically generates a menu sub-item for each sub-page, excluding the pages specified in the Exclude field, and up to the level specified in the Depth field. Any pages selected in the Headings field will be made non clickable. Please note that, if you add sub-items to a PageTree item, they will be ignored and won’t be displayed in your live menu.
- type Post: this menu item points to the single post page whose post ID is specified in the Post ID field.
- type SearchBox: this menu item displays a search box with an optional submit button whose text is specified in the Button field.
- type External: this menu item points to the static URL specified in the URL field.
- type PHP: this menu item points to the URL returned by the PHP code specified in the PHP code field (see Meta links with Menubar 4.9 for examples).
- type Custom: this menu item is custom built with the HTML specified in the HTML field – for experts only!
For each menu item you can also specify two optional fields:
* CSS class: the optional CSS class you wish to apply to this menu item (useful for customizations, see later); multiple classes can be entered, separated by spaces.
* Attributes: the optional HTML attributes you wish to apply to your menu item (e.g. target=”_blank”, or title=”click me!”); multiple attributes can be entered, separated by spaces.
[back to Contents]
Menubar templates
Menus built with Menubar are styled using Menubar templates.
A Menubar template is a folder inside the wp-content/plugins/menubar-templates folder. Each template folder contains a PHP script named wpm3.php, one or more stylesheets, and possibly a few images.
To install a Menubar template:
a) Download the template archive from the Download page and unzip it;
b) Upload the resulting folder, without renaming it, to wp-content/plugins/menubar-templates.
To apply a Menubar template to one of your Menubar menus:
1) From the Appearance – Menubar administration panel select the menu to be styled, and click Edit Menu;
2) Select the template and the stylesheet to apply, and click Update Menu. Done!
To customize a Menubar template you can edit the CSS rules contained in one of the stylesheets of that template. As already mentioned, you can also apply different CSS classes to individual menu items in order to better control the presentation of your menus.
[back to Contents]
Conclusions
I hope you like Menubar. If you have suggestions for improvement, if you need some help, or if something is not working for you as expected, just write me a comment (please be patient if I can’t answer immediately).
Happy menus, with the WordPress Menubar Plugin!
I’m having two issues:
1: Category links will only point to mydomain.com/category/. Regardless of what I enter into the “category ID” field. I know with certainty my category ids and links. I tried entering the URL of my categories as an external URL, but unfortunately this disables the “current category” function!
2: How can I specify a fixed width for my menu’s links? My links vary in size from 2 characters all the way up to 10, and having a small box for my 2-character link just doesn’t cut it for me.
Would really appreciate some input on this! Otherwise, I think your plugin is amazing. I was able to edit the CSS for my text, highlighting, and current menu options. The only drawback I have are the two issues I just mentioned.
Thanks for creating a great plugin!
Hello David,
I’ve received your comment, and I’ll need a few days to look into these problems. I’ll be back to you asap!
Hi Andrea,
Hope all is well with you. We’ve been using your 2.3 successfully for a while and thank you for all your help so far.
I’ve got a test site which now has WP 2.7.1 and Menubar 3.0 on it.. but I cant seem to get the sub-categories to show
I’ve selected “CategoryTree: a category page, with subcategories” and I can see the appropriate category has sub categories. I then select “Suckerfish with sf-blue.css” .. but the sub menus dont appear.. I cant understand what Im doing wrong or how to make the sub menus appear..
I read Michaels and your comments above and rechecked .. but cant see an issue.
Any help, gratefully appreciated as always
Thanks and regards
Kash
Hello Kash,
are your subcategories empty? If so, WordPress doesn’t show empty categories. If not, I need a link to your test site to look at the problem. Please let me know!
Andrea,
Version 3.0 fixes the bug which left my top level navigation appear deselected when a user was on a sublevel. This happened when I used the ‘CategoryTree’ type under the ‘Add Menu Item’.
Thank you so much for eliminating that bug! Your plugin now works flawlessly. Kudos.
Regards,
Mesonto
Hi Andrea thanks for the plugin. This is the first one I have been able to get working because I am brand new to WordPress and just learning. Your instructions were great and I was able to even edit the style sheet, thanks!
One thing I cannot figure out is this. mywebsite.com use to be an html page, but when I installed WordPress the blog now shows as the mywebsite.com page even though it is really mywebsite.com/blog
I really don’t understand this stuff but I see when I come in the site on mywebsite.com the menu bar does not show, but when I come in on mywebsite.com/blog it does show. Can you or anyone else tell me why please. Thanks for any assistance
p.s. sorry I had a brain cramp and did not add right the first time I tried to submit..LOL
Mesonto: thank you for your kind words, I’m glad you find Menubar useful!
Steve: I see that now your site displays the menu at site.com and at site.com/blog too. If you wish to remove the WordPress access from site.com, probably you should delete (or rename) the index.php file in the main site folder, leaving the /blog folder untouched.
Hi! Just installed v3. Nice upgrade. Thanks!
A question: the sub pages all display BEHIND the content, although the top level menu items display correctly. How do I get the subsections to drop down, IN FRONT of the Content?
Thanks
Hi Sebastian,
please send me a link to the page displaying the problem – that would help me investigate the issue. Thank you!
Hi,
the project I’m working on needs different backgrounds for every main-link. And since IE6 doesn’t understand multiple classes, I did a small change in the wpm-menu.php, so that id’s would be used instead of classes. The class itself I need for the active state of the link.
go to line 13 and add the second line from the following:
$selected = $item->cssclass? ” id=\”$item->cssclass\”" . ” class=\”$item->cssclass active selected\”": ” class=\”active selected\”";
I hope this can help anybody
Hi Tom,
I’ll add your patch to the next Menubar release, thanks for your contribution!
Hi Andrea,
Sorry for the late reply regarding sub-categories not appearing – its all fixed now.
Works beautifully
Keep up the fantastic work.
All the best,
Kash
Hi Andrea,
This is exactly the plug-in that I’ve been looking for. I installed 3.0 (not an upgrade) and unfortunately I’m having some problems with the dropdown menu. I am using the Atahualpa theme.
I can get the Suckerfish blue theme to work, but not the other themes. (I prefer the Basic Red.) Can you either help me get the Basic Red working, or instruct me on how to change the coding for Suckerfish from blue to red?
Thanks for your help,
Carol
Hi Carol,
it’s fairly simple to change the colors in the Suckerfish template. Just open the file
wp-content/plugins/menubar/Suckerfish/sf-blue.css
with a text editor, e.g. notepad, and replace each color code:
#1874CD with #990000 (the background color)
#1C86EE with #CC0000 (the active color)
#2EB0FF with #FFFFFF (the top and left border color)
#104E8B with #660000 (the right and bottom border color)
You should replace every occurrence of the old color code with the corresponding new color code.
Save the file, and enjoy you red Suckerfish menu!
Hi Andrea,
Is it possible to get the Suckerfish template centered instead of starting on the left?
Thanks, Wessel
I’m using the suckerfish w/ blue css.
Is it possible to eliminate the dead space? I have a solid blue line going across my screen, and I would like the menu to just “stop” once it displays all of the categories, instead of having the menu continue across the screen.
thx!
A second issue is that the text in my menu is that my active link’s text goes down a few pixels. How can I sort get all of the text to align properly?
Wessel: you could try adjusting the left and right padding, like this:
.sf-blue {
...
padding: 0 50px;
...
}
David: you could remove the background, like this:
.sf-blue {
...
background: #1874CD;...
}
For your second question I’m in the dark, sorry … do you see the same problem with the original CSS too?
Hi Andrea,
I am unable to add submenus/drop down. what should I do? I guess I added correctly in the parent section..
You can see this menu completed so far in the bottom of my website..
Hi Danny,
not every template supports multi-level menus, and right now only Suckerfish does. You could use Suckerfish as a starting point, then modify the CSS to adapt it to your site.
Thanks Andrea,
This manual center method is good enough for me
.
Goodnight,
Wessel
Suckerfish worked Andrea.. it looks great.. thanks a ton..
Andrea,
The menu works fine and its looking real cool. But in IE its showing an error. Firefox no error message. Can you please check my website and tell me why?
Hi Danny,
I can’t see an error message in IE right now, but I know that debugging IE is always a nightmare. I noticed that at the moment your home page doesn’t validate, could that be part of the problem?
Andrea,
Could you please inform me what has changed in v3.1 from v3.0?
Regards,
Mesonto
Hi Mesonto,
sorry I posted the changelog info only on wordpress.org and only today I posted it also on this site.
The only change is the location of the template folders, so your template customizations won’t be overwritten by the next automatic upgrade procedure.
This last time the automatic upgrade procedure *will* overwrite the template folders so, before upgrading, you have to create a new menubar-templates folder in wp-content/plugins and move the template folders (Basic, Suckerfish and others if any) from wp-content/plugins/menubar to
wp-content/plugins/menubar-templates.
As usual, you’ll find all the details in WP Menubar 3 documentation or in the WordPress Plugin Directory.
Andrea,
Thank you for the clarification I knew that was happening but I didn’t know if there were other changes as well.
Regards,
Mesonto
Is it possible to allow users to switch menus? I’m designing a website that caters to multilingual users. I have designed 3 separate menubars and would like to offer users a way to select one that caters to their language needs.
Thanks again! Love love love this plugin.
Hello David,
you could use the same solution I’m using in this site. When you click on English or Italiano under SELECT LANGUAGE, a custom PHP code in header.php calls the English or Italian menu. You’ll need to store the preference in a cookie too, otherwise the menu will revert to its default state on the next page.
Another possibility is to use a multilingual plugin. Menubar is compatible with qTranslate, and possibly with other multilingual plugins. Hope this helps!
Andrea
Thanks for the plugin. It works fine but there seems to be a problem in the ordering of submenus.
As per my testing, the order indicated in the tool is respected only when the head of the submenu is of type “Heading”. When it is a “PageTree” type, the submenu items are displayed in alphabetic order and ignore the order indicated.
I’m using the Suckerfish sf-blue.
Regards
JC
Hello JC,
the PageTree and the CategoryTree types are generated in wpm-menu.php by the WordPress functions wp_list_pages() and wp_list_categories() respectively.
At the moment the only way to change the page tree or category tree order is to modify the function calls inside wpm-menu.php.
Another way could be to build the submenus one item at a time, it’s more time consuming but definitely simpler.
Hello Andrea,
I find a different way to manage it.
1) Go to Appearance / Widgets / Contents: Setup “Sort by:” to “Page Order”. (By default it is “Alphabetic”)
2) Go to each page and assign an order using the “Order” field. Be sure to not duplicate numbers.
And now works in the order assigned on each page. It ignores, of course, the order assigned in the menubar tool.
I still think it would be better that it respects the order in the menubar tool, instead of the generic Pages widget.
Thanks!
JC
Hello JC,
that’s a clever way to reorder your Page Tree! With your permission, I’d like to put your suggestion in a post by itself, to better share it with all our readers. I’ll add a link to your site, if you wish to send me the address. Thank you!
Hey Andrea,
really great plugin. Thanks for that!
I have a little suggestion as I THOUGHT I have an IE6 bug. I used spaces while naming my first menu. As IE6 didn’t show me any submenu I realized that this name is used as an ID in the JavaScript. I got rid of the spaces and everything worked smoothly. I would suggest to either list the characters that can be used or replace space with underscore.
Sorry to not provide you with the code as my PHP is really crappy …
Cheers and thanks again!
Hey Andrea
I’m trying to upgrade from 2.2 to 3.2.
Unfortunately I’m not very good at php!
I can’t remember how I managed to get 2.2 to do this -
http://www.streetsweeper.net.au/menubar2.2.png
When 3.2 does this-
http://www.streetsweeper.net.au/menubar3.2.png
Not the colours, just the vertical position of the menu!
Can you help?
Thanks, Toby
Andrea,
I am getting this “WP Menubar error: Folder wp-content/plugins/menubar-templates is empty!” error.
The folder is there and so are the files inside. Why is this? Could you please explain?
Andrea…
Somehow it is all good now! Thanks anyway.
Albert: Thank you for the bug report, I’ll fix that asap with the next version!
Toby: Sorry I just saw the latest messages, I’m glad the problem went away!
Gautham: I’ll need your help to understand that problem, could you please send me names and permissions of all the files in the menubar-templates folder? Thank you!
I’m looking for something to add a menubar for wordpress and I found your plugin.
I have been wondering about it, so thanks for writing. I’ll certainly be subscribing to your posts.
Dear Andrea
I found an even easier way to make this work as I want. Instead of declaring the page on the top level as PageTree, I have declared it as Page. Now the child pages obey the order specfied in the Menubar admin screen.
Sorry for not posting yet my URL, it is in the works now
. As soon as I have it complete, I will take your word on it.
Great plugin!
Now I’m trying to figure out how to extend the width of a menu
… having a lot of fun researching.
Thanks
JC
Dear Andrea
It was simpler than I thought.
Just changed the width values and voila, works perfect. This plugin is well organized and easy to understand.
In the future, I’d like to try using the CSS Class for the Menu item, so I can add for example a “New!” label next to a menu item recently posted. Here I have some question:
1) Where do I include the CSS code for the Menu item? Is it in the sf-blue.css? At the end of it?
2) Does this CSS overwrites what was originally in the sf-blue.css or extends it? Do you have any examples?
Thanks again!
JC
Hello JC,
the CSS class field just adds the specified class (or classes) to the existing ones for that menu item.
Then you have to add a rule to the template CSS file (e.g. to sf-blue.css) to style that new class and give that menu item a different look.
Andrea,
.
Would you kindly please e-mail me?
I want to send you something I have been working on. It is related to the menubar plugin. I think you’ll like it
Regards
JC
here is the list of files and their permissions
b-blue.css 644
b-green.css 644
b-red.css 644
green.gif 644
sf-blue.css 644
sf-grey.css 644
sf-grey.png 644
sf-vertical.css 644
shadow.png 644
suckerfish.php 666
template.php 644
and the menubar-templates folder is 755
Thank you in advance andrea
Hello Gautham,
the menubar-templates folder structure should be like this:
menubar-templates (main folder)
- Basic (folder inside menubar-templates)
- – wpm3.php (file inside Basic)
- – b-blue.css (file inside Basic)
- – b-green.css (file inside Basic)
- – b-red.css (file inside Basic)
- – green.gif (file inside Basic)
- Suckerfish (folder inside menubar-templates)
- – wpm3.php (file inside Suckerfish)
- – sf-blue.css (file inside Suckerfish)
…
and so on. If your structure is different, just empty the menubar-templates folder and upload the Basic and Suckerfish folders again. Please let me know if that works!
Dear andrea,
Now it shows the templates.
Sorry for the trouble. Just another newbie
Thank you, andrea
Hello Gautham,
don’t worry, now I’m glad the problem is solved so you can enjoy your Menubar!
Hi,
Just wanted to say thank you for this great pug-in, I use it on many websites that I build.
Keep up the good work,
Daniel
Thank you Daniel!
Andrea, as promised, I’m sharing my website details as it is live now: http://www.thesmalltrader.com
It proudly uses the menubar with the redirect technique.
Thanks!