Basic usage - lokothodida/gs-custom-menu GitHub Wiki
Creating a menu
Go to the Pages tab and click 'Customize Menus'. You should have a default menu existing there with just one item (a link to the index page). You can either click on it to edit it, or 'Create' to build a new menu.
The name field provides the name of the menu (alphanumeric, a-z; this will also be the name for the xml file). Clicking +Item will let you add items to this menu, and x will remove said item. Items can be dragged into the desired order, and structured hierarchically by (un)indenting with the left and right arrow links.
Properties
- Title: label for URL link
- URL: actual URL itself (can be relative to the site or an external link - if the latter, provide the full address)
- Slug: really, the class given to the housing list in the outputted HTML (for CSS styling)
- Target: determines whether the link is opened in the current window, in a new window, etc...
When done, click 'Save Changes' to save your menu.
For an existing menu, changing the name at the top of the page will automatically rename the menu for you.
Displaying the menu
From a page
You can call the following placeholder on your page content to output a menu:
(% custom_menu menuname %)
Replacing menuname with your menu's name.
With PHP code
To call the direct PHP function, simply use:
get_custom_menu('menuname');
Again, replacing menuname with your menu's name.
Example output
Note
If you call the PHP function, it is best to wrap it in <ul>
tags so that the nested lists display correctly (this is done automatically for the page placeholders).