How to Create and Delete a WordPress Page Using WP-CLI

In This Tutorial:

Create a Page Delete a Page

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

    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 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

    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 post delete 156

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!

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

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!