Creating custom menus is now possible in WordPress via drag and drop interface, make your own menus using a combination of external links, categories or pages in a few clicks.
It is necessary to add the line of code:
add_theme_support( 'menus' );
functions.php file if you do not use the default theme or a theme does not support Menus for WordPress.
To have this new feature, you must have completed the upgrade to WordPress 3.0 (or higher).
We urge you as these features are awesome.
The menu navigation can be selected directly from the Appearance menu in your WordPress administration. With the new TwentyTen, you can design your navigation bars too.
The major problem is that most themes do not include this kind of default menus.
Therefore, we will see how to dispose of this feature of WordPress through this step by step tutorial.
First, open the
header.php of your theme or module via the WordPress editor, either using a text editor for Windows or Mac OS X (for example, Coda).
We must now find a place to position our menu. This is the first difficulty of the tutorial. You must know what are the different elements of the source code.
By helping the Firebug extension for Mozilla Firefox, you should be able to identify between which tags you want to position your custom menu.
Then insert the following snippet:
<? Php wp_nav_menu ($ args);?>
As you can see, it is possible to define the arguments between the parentheses instead of $args .
Here is the list of allowed parameters extracted from the WordPress codex :
$id : ID of the menu;
$slug : the permalink menu;
$menu : menu name, useful if you create multiple;
$container : The parent element of the menu, the default tag div is applied;
$container_class : the class of the parent element;
$container_id : ID of the parent element;
$menu_class : class Menu;
$format : format of the menu, we recommend starting with a ul list
$fallback_cb : if the menu is not created in WordPress, you can add a command to overcome this. By default, pages are listed;
$link_before : Text to display before the menu;
$link_after : text to be displayed after the menu;
$before : see the text before the link;
$after : display text after the link;
$echo : By default, the value is True ;
All these parameters are optional. So you can limit after default code that surround us here for a tag div to facilitate management styles:
<? Php wp_nav_menu ();?>
Once your menu is positioned where you want, save the file.
You may will note the many available arguments allow customization very highly in terms of CSS … even if we could go even further.
Management of customized menu in WordPress
Under the administration WordPress, open the module and then click Appearance menu.
Indicate the first name of the menu. It is possible to create multiple, and if that is the case, you must provide the argument via menu .
Then click the Create button menu.
To the left you will notice the presence of 3 modules:
- External links: very convenient to insert links to other websites;
- Pages: To add pages to your WordPress menu;
- Categories: WordPress to insert categories in your navigation bar;
You just have to check the items of your choice – module after module, then click Add on the menu.
To rearrange the menu, drag and drop the different elements in the knowledge that it is possible to create sub-menus. To do this, move the item to the right to create a nesting.
Remember to click the Save menu to save your changes.
To see the results, open your site in a new tab. Accordingly adjust your menu to suit your needs.
You can add a second menu by clicking the button more shaped, located adjacent to the newly created menu in WordPress administration.