Once you have created a menu, you can display it on your website by assigning it to an available location. The available locations are determined by the theme you are using. WordPress themes include various menu locations built-in, where you can assign menus to appear. In this guide, you will learn how to assign a location to a menu using WP-CLI to display it on your WordPress website.
Assign Menu a Location
The following instructions will show you how to use the wp menu location sub-command to list the available locations for menus.
SSH into your server as the cPanel user that owns the website you would like to work with.
Use the cd command to switch to the document root directory of your website.
Example: cd public_html/wpNOTE: Be sure to replace public_html/wp with the actual path to the document root directory of your website.
Run the following command:
wp menu location assign primary-nav topNOTE: Be sure to replace primary-nav with the actual name of your menu and top with the actual name of the location.
The output will be similar to the example below:
[email protected] [~/public_html/wp]# wp menu location assign primary-nav top Success: Assigned location to menu.
Congratulations! Now you know how to assign a location to a menu using WP-CLI to display the menu on your website.
Learn more about WP-CLI, the command-line interface for WordPress, and how to streamline your WordPress maintenance workflows!