bricks_create_menu
Overview
Creates a new WordPress navigation menu with items and optionally assigns it to a theme location. Menu items support multiple object types (page, post, custom URL, category, tag) and nested children for dropdown submenus.
This tool is typically used during Phase 3 when creating header and footer templates. The created menu can then be assigned to a nav-menu element using bricks_assign_menu_to_element.
Key Features
When to Use
To create a main navigation, footer links, or mobile-specific menu
When the site needs a new menu for a sidebar, mega menu, or utility navigation
After all pages are created so real URLs can be used instead of placeholders
When NOT to Use
When you just need to change a menu assignment on an element — use bricks_assign_menu_to_element
Parameters
namestringREQUIREDitemsarrayREQUIREDlocationstringoptionalCode Examples
Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12
Create Main Navigation
Creates a main navigation menu with a dropdown submenu under Services and assigns it to the primary theme location.
bricks_create_menu({
name: "Main Navigation",
items: [
{ title: "Home", object_type: "page", object_id: 33 },
{ title: "Services", object_type: "page", object_id: 45,
children: [
{ title: "Web Design", object_type: "page", object_id: 46 },
{ title: "Development", object_type: "page", object_id: 47 }
]
},
{ title: "About", object_type: "page", object_id: 50 },
{ title: "Contact", object_type: "page", object_id: 55 }
],
location: "primary"
})Common Mistakes
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018
Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48
Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Tips & Warnings
Default URL trap: When using object_type « custom » without specifying a url, WordPress defaults to « # ». Always provide a real URL or use page/post object types with object_id instead.
Mega menus: To convert a menu item into a rich mega menu, first create the menu normally, then use bricks_create_mega_menu to assign a Bricks template to a specific menu item.