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!

John-Paul Briones Content Writer II

John-Paul is an Electronics Engineer that spent most of his career in IT. He has been a Technical Writer for InMotion since 2013.

More Articles by John-Paul

Was this article helpful? Join the conversation!