How to Assign Menus to Locations Using WP-CLI

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.

  1. SSH into your server as the cPanel user that owns the website you would like to work with.

  2. Use the cd command to switch to the document root directory of your website.

    Example: cd public_html/wp

  3. Run the following command:

    wp menu location assign primary-nav top

    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!

IC
InMotion Hosting Contributor Content Writer II

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

Was this article helpful? Join the conversation!

Questions about our MailChannels Deployment? We have answers and are here to help!Learn More
+