Menus

Use menus when the same collection of links must appear on multiple pages. Most often menus are used to navigate a website or a section of a site, but they are not limited to navigation.


Overview

Here’s an example menu:

Menus are essentially a display wrapper for WordPress menus, and thus require a WordPress menu to function. Create a WordPress menu first, and then add the menu component to the page.

On mobile, menus present as a drop-down list, and show the menu title for the drop-down button. By default, the menu title is the name of the WordPress menu, but this can be overridden. On desktop, the menu title is hidden by default, since the full menu is visible, but this can be overridden as well.

Menus can show, at maximum, two levels of hierarchy. In other words, top-level links (level 1) may each have a drop-down of secondary links (level 2), but secondary links may not have further drop-downs (level 3, etc). In general, menus with fewer links perform better, and most menus on well-constructed sites will only need one level of hierarchy.

Adding a Menu

On sites using the Block Editor, menus (Menu block editor icon) can be added from the block library, under the Component Library section. Menu options can be set in the sidebar.

On sites using the older Visual Editor, menus can be implemented by using the shortcode (see the below documentation).


Technical Details

Menus can be implemented with the shortcode cl-menu.

[cl-menu name="my-menu"]

Attributes

name

(string) (optional)

The name of the menu to use

(default: WP primary)

depth

(num) (optional) (values: 12)

Set how many levels of hierarchy to include

(default value: 1)

title

(string) (optional)

Set a custom menu title

(default value: name)

showtitle

(bool) (optional)

Set show the menu title on desktop

(default value: false)

id

(string) (optional)

Set an ID for the menu container

(default value: none)

class

(string) (optional)

Set custom CSS class(es)

(default value: none)