WP-CLI allows you to manage your website built on WordPress directly from the command line. Once you are familiar with the syntax and commands available, you will be able to quickly change common elements of your website, such as menus.

Menus are essential in providing a focal point for your visitors to find important information contained on your website.

Here's how you can create and delete menus from the command line in WP-CLI.

 

Creating a menu

We can create a simple menu, using the subcommand wp menu created. To create a new command line menu in WP-CLI, follow the steps below:

- Log in to the server via SSH with the cPanel user who owns the website you want to work on.

- Use the cd command to access the root folder of your website eg:

cd public_html/wp

Replace public_html/wp with the actual path to the root folder of your website.

 

Run the following command:

wp menu create primary-nav

Replace primary-nav with the name you want to give to the menu you wish to create.

 

The command will return an output similar to:

[email protected][~/public_html/wp]# wp menu create primary-nav Success: Created menu 3.

Deleting a menu

If you want to delete a created menu, you can do this using the wp menu delete subcommand. To delete a menu via the command line in WP-CLI, follow the steps below:

- Log in to the server via SSH with the cPanel user who owns the website you want to work on.

- Use the cd command to access the root folder of your website eg:

cd public_html/wp

Replace public_html/wp with the actual path to the root folder of your website.

 

Run the following command:

wp menu delete primary-nav

Replace primary-nav with the name you want to give to the menu you wish to delete.

 

The command will return an output similar to:

[email protected] [~/public_html/wp]# wp menu delete primary-nav Success: Menu(s) deleted.

 

For assistance in applying the above instructions on HostX servers please contact us. HostX offers the fastest WordPress hosting and can help you solve your problems.

Was this answer helpful? 0 Users Found This Useful (0 Votes)