In This Tutorial:
WP-CLI is a tool available with any of InMotion Hosting’s WordPress Hosting plans. This ingenious suite of tools allows you to work on your WordPress websites from the command line. In this guide, you will learn how to create and delete a WordPress Page from the command line using the WP-CLI command, wp post.
Add a Page
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/wp
NOTE: Be sure to replace public_html/wp with the actual path to the document root directory of your website.Run the following command:
wp post create –post_type=page
The output will be similar to the example below:
[email protected] [~/public_html/wp]# wp post create --post_type=page Success: Created post 157.
Delete a Page
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/wp
NOTE: Be sure to replace public_html/wp with the actual path to the document root directory of your website.Run the following command:
wp post delete 156
NOTE: Be sure to replace 156 with the actual ID of the Page you would like to delete.
The output will be similar to the example below:
[email protected] [~/public_html/wp]# wp post delete 156 Success: Trashed post 156.
Congratulations! Now, you know how to create and delete WordPress Pages, using WP-CLI.
Learn more about WP-CLI, the command-line interface for WordPress, and how to streamline your WordPress maintenance workflows!