Manage WordPress Using WP-CLI

Manage WordPress Using WP-CLI

All of our Shared and Reseller packages have a very powerful command line interface for managing WordPress call WP-CLI installed by default. Though this document was meant to offer a lot of basics and go through some very important features of WP-CLI it is recommended to explore the official documentation for additional information: https://developer.wordpress.org/cli/commands/

Accessing WP-CLI

1. Login to cPanel and click on the button that says Terminal. In most cases you enter your home directory upon accessing Terminal. Type cd public_html or cd foldername to navigate to your WordPress site. For instance, if you have a domain called mycooldomain.com in /home/eric/mycooldomain.com  you would type cd mycooldomain.com. If you had a domain in your public_html folder you would just type cd public_html.

2.  Type wp or wp help to display the default help message. This will display a list of commands. You can always enter wp help <commandname> for more information about a command. For instance: wp help help will display information about the help command. NOTE: When accessing help in wp-cli, you can type q to quit and space bar or the up or down arrow keys on your keyboard to navigate through the help files. 

Useful WP-CLI Commands

Below is a list of useful commands with an explanation for each command. This list is not exhaustive, but this will provide some very useful commands for managing your WordPress site from the command line. 

  • wp help - Lists all commands.

  • wp help <command> <optional subcommand> - Get more help on a specific command and display possible subcommands For instance, wp help help ,  wp help plugin , or wp help core download

  • wp core download - Download and extract all default WordPress core files to your current directory. You would use this if somehow WordPress files became corrupted or were missing. In most cases plugins, themes, etc should not update these files, so it is usually safe to run this command to restore your core files as long as you have a backup just in case. NOTE: If WordPress is already installed, you can also run wp core download --force

  • wp core version - Show WordPress core version

  • wp core update - Update to most recent WordPress core version.

  • wp plugin list - List all installed plugins

  • wp plugin search <keyword> - Search for plugins that contain keyword. For instance wp plugin search yoast will provide all plugins that contain "Yoast" in the name or description of the plugin. The slug name for each plugin is what you will enter to install or remove the pluginblobid0.png

  • wp plugin install <slug name>. Installs a WordPress plugin with the slug name provided in wp plugin search. For instance, when you searched in the above example you found out wordpress-seo is the slug name for Yoast SEO. To install this plugin you would just enter wp plugin install wordpress-seo.

  • wp plugin install <slug name> -activate - Installs a WordPress plugin with the slug name provided and activates the plugin. 

  • wp plugin activate <slug name> - Activates a WordPress plugin. For instance in the example above you could type wp plugin activate wordpress-seo.

    • Note: You can utilize this command to activate multiple domains as well e.g wp plugin activate wordpress-seo duplicate-post yoast-test-helper

  • wp plugin update <slug name> - Updates a WordPress plugin. In the above example you would type wp plugin update wordpress-seo

  • wp plugin deactivate -all - Deactivates all plugins. This can be helpful if one or more plugins is causing an issue with your site. 

  • wp plugin activate -all - Activates all currently installed plugins.

  • wp theme list - Lists all themes installed

  • wp theme install twentytwenty -activate - Installs and activates the twentytwenty theme.

  • wp theme delete twentytwenty - Deletes twentytwenty theme.

  • wp theme disable twentytwenty - Disable twentytwenty theme.

  • wp search-replace 'oldstring' 'newstring' - Search the database for oldstring and replace with newstring. For instance wp search-replace 'oldsite.com' 'newsite.com' would replace all instances of oldsite.com with newsite.com within the database.

  • wp user list -all  - List all WordPress users

  • wp user list -role=administrator - List all WordPress administrator users

  • wp user reset-password <username> - Reset password for the username you choose.

  • wp config get - View wp-config configuration

  • wp config set WP_DEBUG false - disable WP_DEBUG mode

  • wp config set WP_DEBUG true - enable WP_DEBUG mode

These are just a couple useful WP-CLI commands. To learn more you should check out the official documentation at https://developer.wordpress.org/cli/commands/


    • Related Articles

    • How Can I Monitor The Resources That My Account is Using?

      Viewing Current Resource Usage You may check the current resource use of your account using a few different methods: Top (via Command Line) You may use the Top command in cPanel's Terminal Application or SSH to see how much resource you are now ...
    • Giving Access to Developers

      There are several options available to you about how a developer may access your website in the event that you need to provide them access in order for them to construct or maintain it. Before we begin, we advise you to always create a backup of your ...
    • What is an Entry Process and a Process Limit?

      After logging into cPanel, you saw a few items on the right side of the screen that are highlighted in red. What are these? A process is any concurrent action or operation that is being performed by a user. The cPanel on our shared servers is ...
    • What is Shared Hosting?

      A shared hosting plan is a kind of service where several websites are hosted on one physical server. Because so many people share the server's resources, this kind of hosting is inexpensive. This is the most economical option for small businesses to ...
    • Troubleshooting Email DNS with Webmail

      Of course! In order to resolve DNS (Domain Name System) problems with webmail, you must examine and confirm the different DNS entries connected to your domain. This is a step-by-step tutorial to assist you in locating and fixing any possible DNS ...