{"id":37942,"date":"2022-11-07T07:00:21","date_gmt":"2022-11-07T15:00:21","guid":{"rendered":"https:\/\/dhblog.dream.press\/blog\/?p=37942"},"modified":"2025-05-21T18:47:10","modified_gmt":"2025-05-22T01:47:10","slug":"guide-to-wp-cli","status":"publish","type":"post","link":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/","title":{"rendered":"What Is the WordPress CLI (And How Can You Use It)?"},"content":{"rendered":"\n<p>As you get more comfortable <a href=\"https:\/\/www.dreamhost.com\/wordpress\/guide-to-developing-a-wp-theme\/\" target=\"_blank\" rel=\"noopener\">developing WordPress<\/a>, you\u2019ll want some tools that will help you complete your tasks quickly and efficiently. The WordPress admin dashboard is intuitive and comprehensive, but it can also be time-consuming to navigate.<\/p>\n\n\n\n<p>What if you want to manage your site more directly, with just a few easy commands? This is where the <a href=\"http:\/\/wp-cli.org\/\" target=\"_blank\" rel=\"noopener\">WordPress Command Line Interface (WP-CLI)<\/a> comes in handy.<\/p>\n\n\n\n<p>The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. It\u2019s also very comprehensive, with a wide variety of potential commands. Almost anything you can do on the back end of your site, you can do much faster using the WP-CLI.<\/p>\n\n\n\n<h2 id=\"h-an-introduction-to-the-wordpress-command-line-interface-wp-cli\" class=\"wp-block-heading\"><b>An Introduction to the WordPress Command Line Interface (WP-CLI)<\/b><\/h2>\n\n\n\n<p>Like most WordPress users, you\u2019re probably very familiar with the WordPress admin area. It works well, but it\u2019s not the only option for managing your site. In fact, it\u2019s not even the most direct or efficient way of doing so. Having a graphical interface is certainly preferable for some users. However, it does mean you\u2019ll spend a lot of time navigating through menus or waiting for pages to load.<\/p>\n\n\n\n<p>Enter the <a href=\"https:\/\/www.dreamhost.com\/blog\/wp-cli-beginners-guide\/\" target=\"_blank\" rel=\"noopener\">WordPress Command Line Interface (WP-CLI)<\/a>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1670\" height=\"452\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/wordpress-cli.jpg\" alt=\"WordPress CLI\" class=\"wp-image-37958 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/wordpress-cli.jpg.webp 1670w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/wordpress-cli-300x81.jpg 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/wordpress-cli-1024x277.jpg 1024w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/wordpress-cli-768x208.jpg 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/wordpress-cli-1536x416.jpg 1536w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/wordpress-cli-600x162.jpg.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/wordpress-cli-750x203.jpg.webp 750w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/wordpress-cli-100x27.jpg 100w\" data-sizes=\"(max-width: 1670px) 100vw, 1670px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1670px; --smush-placeholder-aspect-ratio: 1670\/452;\" \/><\/figure><\/div>\n\n\n<p>As the name suggests, this tool enables you to perform administrative tasks on your WordPress site using a <a href=\"https:\/\/www.learnenough.com\/command-line-tutorial\" target=\"_blank\" rel=\"noopener\">command line<\/a>. With this method, you can complete a task by simply typing in a line of code and hitting <i>Enter<\/i>.<\/p>\n\n\n\n<p>The beauty of the WP-CLI is that it gives you direct control over your site. Anything you can do in the WordPress admin dashboard, you can do using the WP-CLI instead. It\u2019s not nearly as complicated as you may fear, and there are <a href=\"https:\/\/www.codecademy.com\/learn\/learn-the-command-line\" target=\"_blank\" rel=\"noopener\">plenty of resources<\/a> available if you want to learn more about it.<\/p>\n\n\n\n<p>To use the WP-CLI, you\u2019ll need to install it on your WordPress site. Let\u2019s look at this process in more detail now.<\/p>\n\n\n\n<h2 id=\"h-how-to-install-the-wp-cli-on-your-wordpress-website\" class=\"wp-block-heading\"><b>How to Install the WP-CLI on Your WordPress Website<\/b><\/h2>\n\n\n\n<p>If your site is hosted with DreamHost, it will already have the <a href=\"https:\/\/help.dreamhost.com\/hc\/en-us\/articles\/214693248\" target=\"_blank\" rel=\"noopener\">WP-CLI installed<\/a>. If you need to, however, you can also install this tool manually.<\/p>\n\n\n\n<p>You\u2019ll first need to make sure that your environment is compatible, meaning that it conforms to the following specifications:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A UNIX-like environment (OS X, Linux, FreeBSD, Cygwin)<\/li>\n\n\n\n<li>PHP 5.6 or later<\/li>\n\n\n\n<li>WordPress 3.7 or later<\/li>\n<\/ul>\n\n\n\n<p>That first point might be a problem for some users. The WP-CLI is made with UNIX-like environments in mind and has limited support for Windows. It is still possible to <a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/installing\/#installing-on-windows\" target=\"_blank\" rel=\"noopener\">install it on Windows<\/a>, but beware that it may require some <a href=\"https:\/\/deluxeblogtips.com\/install-wp-cli-windows\/\" target=\"_blank\" rel=\"noopener\">additional tinkering<\/a>.<\/p>\n\n\n\n<p>To <a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/installing\/\" target=\"_blank\" rel=\"noopener\">install the WP-CLI<\/a> in one of the environments on the above list, you\u2019ll need to use <a href=\"https:\/\/help.dreamhost.com\/hc\/en-us\/articles\/216041267\" target=\"_blank\" rel=\"noopener\">Secure Shell (SSH)<\/a> to download and configure the necessary files. First, you need to download the <i>wp-cli.phar<\/i> file to your root directory, using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -O https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar<\/pre>\n\n\n\n<p>You should then check to make sure that the file is working, using another command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">php wp-cli.phar --info<\/pre>\n\n\n\n<p>Next, you\u2019ll want to make the file executable, which will enable you to use the wp command. You\u2019ll also want to move it to another directory. This final command will perform both tasks:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chmod +x wp-cli.phar\n\nsudo mv wp-cli.phar \/usr\/local\/bin\/wp<\/pre>\n\n\n\n<p>With that, the WP-CLI should now be successfully installed. You can test it by running the command wp &#8211;info. If everything works, you\u2019ll see information about your version of the WP-CLI displayed.<\/p>\n\n\n\n<p>That\u2019s it! You\u2019re now ready to use this tool to manage your site more efficiently. Before we move on, however, let\u2019s run through some alternative methods of installation.<\/p>\n\n\n\n<div class=\"article-newsletter article-newsletter--gradient\">\n\n\n<h2>Get Content Delivered Straight to Your Inbox<\/h2><p>Subscribe now to receive all the latest updates, delivered directly to your inbox.<\/p><form class=\"nwsl-form\" id=\"newsletter_block_\" novalidate><div class=\"messages\"><\/div><div class=\"form-group\"><label for=\"input_newsletter_block_\"><input type=\"email\"name=\"email\"id=\"input_newsletter_block_\"placeholder=\"Enter your email address\"novalidatedisabled=\"disabled\"\/><\/label><button type=\"submit\"class=\"btn btn--brand\"disabled=\"disabled\"><span>Sign Me Up!<\/span><svg width=\"21\" height=\"14\" viewBox=\"0 0 21 14\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n<path d=\"M13.8523 0.42524L12.9323 1.34521C12.7095 1.56801 12.7132 1.9304 12.9404 2.14865L16.7241 5.7823H0.5625C0.251859 5.7823 0 6.03416 0 6.3448V7.6573C0 7.96794 0.251859 8.2198 0.5625 8.2198H16.7241L12.9405 11.8535C12.7132 12.0717 12.7095 12.4341 12.9323 12.6569L13.8523 13.5769C14.072 13.7965 14.4281 13.7965 14.6478 13.5769L20.8259 7.39879C21.0456 7.17913 21.0456 6.82298 20.8259 6.60327L14.6477 0.42524C14.4281 0.205584 14.0719 0.205584 13.8523 0.42524Z\" fill=\"white\"\/>\n<\/svg>\n<\/button><\/div><\/form><\/div>\n\n\n<h2 id=\"h-alternative-ways-to-install-the-wp-cli\" class=\"wp-block-heading\"><b>Alternative Ways <\/b><b>to Install<\/b><b> the WP-CLI<\/b><\/h2>\n\n\n\n<p>As we alluded to earlier, there are actually several methods to install the WP-CLI. We won\u2019t detail all of them in this article. However, we\u2019ll list them out briefly and link to more information on each, so you can choose the technique that best suits your needs.<\/p>\n\n\n\n<p>You can use the following tools to install the WP-CLI on your site:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/installing\/#installing-via-composer\" target=\"_blank\" rel=\"noopener\">Composer<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/installing\/#installing-via-homebrew\" target=\"_blank\" rel=\"noopener\">Homebrew<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/guides\/installing\/#installing-via-docker\" target=\"_blank\" rel=\"noopener\">Docker<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/installing\/#installing-via-deb-package\" target=\"_blank\" rel=\"noopener\">.deb package<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/installing\/#using-a-custom-php-binary\" target=\"_blank\" rel=\"noopener\">A custom PHP binary<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/mediatemple.net\/community\/products\/dv\/360056149791\/how-to-install-wp-cli\" target=\"_blank\" rel=\"noopener\">MediaTemple<\/a><\/li>\n<\/ul>\n\n\n\n<p>Finally, you may want to get involved in developing the WP-CLI yourself. You can easily get involved with its development by using the <a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/guides\/installing\/#installing-via-git\" target=\"_blank\" rel=\"noopener\">Git installation instructions<\/a>.<\/p>\n\n\n\n<h2 id=\"h-5-ways-to-use-the-wp-cli-to-manage-your-wordpress-site\" class=\"wp-block-heading\"><b>5 Ways to Use the WP-CLI to Manage Your WordPress Site<\/b><\/h2>\n\n\n\n<p>The WP-CLI provides total access to your site \u2014 right at your fingertips. There are <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/\" target=\"_blank\" rel=\"noopener\">dozens of commands<\/a> you can use to manage nearly everything from comments to core updates. Plus, you can even create <a href=\"https:\/\/make.wordpress.org\/cli\/handbook\/commands-cookbook\/\" target=\"_blank\" rel=\"noopener\">custom commands<\/a>.<\/p>\n\n\n\n<p>We\u2019re now going to look at just a few of the standard commands available to you. This is to give you an idea of how you can use WP-CLI to manage your site before you dig deeper into the rabbit hole of possibilities.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-install-and-update-wordpress\"><b>1. Install and Update WordPress<\/b><\/h3>\n\n\n\n<p>The most fundamental task you can accomplish with the WP-CLI is to download and install WordPress on your site. The <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/core\/download\/\" target=\"_blank\" rel=\"noopener\">command for downloading WordPress<\/a> is simply:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp core download<\/pre>\n\n\n\n<p>This will download and extract WordPress in the current directory. You can also <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/core\/download\/#options\" target=\"_blank\" rel=\"noopener\">add additional parameters<\/a> to refine the download further. For example, the locale parameter determines which translation of WordPress will be used. This command will download the Brazilian Portuguese version of WordPress:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp core download --locale=pt_BR<\/pre>\n\n\n\n<p>Once downloaded, you can install WordPress using <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/core\/install\/\" target=\"_blank\" rel=\"noopener\">the install command<\/a>. This command contains a number of parameters that configure the setup. Let\u2019s take a look at an example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword --admin_email=info@example.com<\/pre>\n\n\n\n<p>As you can see, this is all fairly self-explanatory. Simply replace the example data in each parameter with your own values. To ensure that everything has worked as expected, you can use the following command to test the installation:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp core version<\/pre>\n\n\n\n<p>This will return the version number of your installation, proving that WordPress has been successfully installed! Now you can make sure it\u2019s updated with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp core update<\/pre>\n\n\n\n<p>If a newer version of WordPress is available, it will be downloaded and installed automatically after you run this command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-manage-themes-and-plugins\"><b>2. Manage Themes and Plugins<\/b><\/h3>\n\n\n\n<p>There are many ways you can manage <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/theme\/\" target=\"_blank\" rel=\"noopener\">themes<\/a> and <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/plugin\/\" target=\"_blank\" rel=\"noopener\">plugins<\/a> using the WP-CLI, so let\u2019s look at some of the basic options now. First, you can use the list command to view a list of your themes or plugins. Using parameters, you can filter the display by items with a specific status (such as inactive) or a particular output format.<\/p>\n\n\n\n<p>For example, if you want to <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/theme\/list\/\" target=\"_blank\" rel=\"noopener\">list all inactive themes<\/a> as a CSV list, you can use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp theme list --status=inactive --format=csv<\/pre>\n\n\n\n<p>You can also <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/plugin\/install\/\" target=\"_blank\" rel=\"noopener\">install a plugin<\/a> by specifying its slug in the plugin directory, providing the path to a local file, or entering the URL for an external file. In this example, we\u2019re also going to activate the plugin at the same time:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp plugin install ..\/my-plugin.zip --activate<\/pre>\n\n\n\n<p>It\u2019s also easy to change the status of a plugin or theme. This command can be used to <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/theme\/enable\/\" target=\"_blank\" rel=\"noopener\">enable a theme<\/a>, which in this example is Twenty Twenty:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp theme enable twentytwenty<\/pre>\n\n\n\n<p>There\u2019s also a command for <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/plugin\/deactivate\/\" target=\"_blank\" rel=\"noopener\">deactivating a plugin<\/a>. In our example, we\u2019ll use this command to disable the Hello Dolly plugin. We\u2019ll also uninstall the plugin at the same time:<\/p>\n\n\n\n<p>wp plugin deactivate hello &#8211;uninstall<\/p>\n\n\n\n<p>Finally, you can search the respective directories looking for a specific <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/plugin\/search\/\" target=\"_blank\" rel=\"noopener\">plugin<\/a> or <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/theme\/search\/\" target=\"_blank\" rel=\"noopener\">theme<\/a>. For instance, let\u2019s search for a theme containing the string \u201cphoto\u201d. We\u2019re also setting it to return three results instead of the default ten:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp theme search photo --per-page=3<\/pre>\n\n\n\n<p>This will display the following table:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1504\" height=\"410\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/table.png\" alt=\"WordPress CLI query table\" class=\"wp-image-37956 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/table.png.webp 1504w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/table-300x82.png 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/table-1024x279.png 1024w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/table-768x209.png 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/table-600x164.png.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/table-750x204.png.webp 750w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/table-100x27.png 100w\" data-sizes=\"(max-width: 1504px) 100vw, 1504px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1504px; --smush-placeholder-aspect-ratio: 1504\/410;\" \/><\/figure><\/div>\n\n\n<p>As we mentioned, this is only a small taste of how you can manage themes and plugins using the WP-CLI. Hopefully, you\u2019re getting a sense of how useful this tool can be.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-create-a-child-theme\"><b>3. Create a Child Theme<\/b><\/h3>\n\n\n\n<p>By using <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/scaffold\/\" target=\"_blank\" rel=\"noopener\">the scaffold command<\/a>, you can generate a <a href=\"https:\/\/www.dreamhost.com\/wordpress\/tutorial-how-to-install-a-wp-child-theme\/\" target=\"_blank\" rel=\"noopener\">child theme<\/a> that includes the <i>functions.php<\/i> and <i>style.css<\/i> files. We recommend that you do this if you want to make changes to an existing theme. When you use a child theme, any customizations won\u2019t be lost after new software updates.<\/p>\n\n\n\n<p>To do this, you\u2019ll simply need to specify the slug for the new <a href=\"https:\/\/www.dreamhost.com\/blog\/why-you-need-a-child-theme\/\" target=\"_blank\" rel=\"noopener\">child theme<\/a>, and for the theme you\u2019re using as the \u2018parent.\u2019 In this example, we\u2019re creating a child based on the Twenty Twenty theme, and we\u2019re giving it the slug twentytwenty-child:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp scaffold child-theme twentytwenty-child --parent_theme=twentytwenty<\/pre>\n\n\n\n<p>If the process is successful, you\u2019ll see a message that the child theme has been created. This will also include the path to its directory:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Success: Created '\/var\/www\/example.com\/public_html\/wp-content\/themes\/twentytwenty-theme'.<\/pre>\n\n\n\n<p>You\u2019ll now find the child theme in the specified template, ready to be edited!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-4-moderate-comments\"><b>4. Moderate Comments<\/b><\/h3>\n\n\n\n<p>Moderating and <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/comment\/\" target=\"_blank\" rel=\"noopener\">managing comments<\/a> is made a lot easier in the WP-CLI, which enables you to quickly create, delete, and edit them. There are many <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/comment\/#subcommands\" target=\"_blank\" rel=\"noopener\">comment subcommands<\/a> you can use, but let\u2019s look at some of the most basic options.<\/p>\n\n\n\n<p>First, you can add a new comment. The following command will add a comment to a post with the post ID of 20, and specifies the contents and author:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp comment create --comment_post_ID=20 --comment_content=\"This is my comment\" --comment_author=\"author-name\"<\/pre>\n\n\n\n<p>Before you manage existing comments, it can be helpful to get a current list. You can do this <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/comment\/list\/\" target=\"_blank\" rel=\"noopener\">with the list command<\/a>, and the results can be filtered in multiple ways. For example, using this command will return a table containing the comment ID and author name for all approved comments on the post with an ID of 3:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp comment list --number=3 --status=approve --fields=ID,comment_author<\/pre>\n\n\n\n<p>This is what the resulting table will look like:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"838\" height=\"414\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/cli-table.png\" alt=\"WordPress CLI query table\" class=\"wp-image-37963 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/cli-table.png.webp 838w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/cli-table-300x148.png 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/cli-table-768x379.png 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/cli-table-600x296.png.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/11\/cli-table-750x371.png.webp 750w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/cli-table-100x49.png 100w\" data-sizes=\"(max-width: 838px) 100vw, 838px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 838px; --smush-placeholder-aspect-ratio: 838\/414;\" \/><\/figure><\/div>\n\n\n<p>If you want to delete comments, you can do that by specifying the comment IDs individually, like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp comment delete 64<\/pre>\n\n\n\n<p>You can also delete multiple comments by separating each ID with a space. In this example, we\u2019re also using the force parameter, which permanently deletes comments instead of adding them to the trash bin:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp comment delete 5 22 64 64 --force<\/pre>\n\n\n\n<p>With a little practice, you can work through your site\u2019s comments very quickly using WP-CLI commands.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-5-update-the-wp-cli\"><b>5. Update the WP-CLI<\/b><\/h3>\n\n\n\n<p>As with every aspect of WordPress, you should always make sure that the WP-CLI is up-to-date. Fortunately, this is very simple. All you need to do is run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wp cli update<\/pre>\n\n\n\n<p>If your version is the most recent available, you will get a message confirming this. However, if a new version can be downloaded, you\u2019ll be prompted to accept the installation. If you select <i>yes<\/i>, the WP-CLI will be updated, and you\u2019ll see a confirmation message:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Success: Updated WP-CLI to 0.23.1<\/pre>\n\n\n\n<p>With that, you\u2019ve updated your installation of the WP-CLI.<\/p>\n\n\n\n<p>By now, you\u2019re beginning to see what you accomplish using this simple interface. There\u2019s <a href=\"https:\/\/help.dreamhost.com\/hc\/en-us\/articles\/214693248\" target=\"_blank\" rel=\"noopener\">more to learn<\/a>, but you should be proud of how far you\u2019ve come already!<\/p>\n\n\n\n<h2 id=\"h-work-more-efficiently-with-the-wordpress-cli\" class=\"wp-block-heading\"><b>Work More Efficiently with the WordPress CLI<\/b><\/h2>\n\n\n\n<p>Speed, accessibility, and efficiency are all traits that any smart developer looks for in their tools. The WP-CLI offers all of these and more while enabling you to manage your WordPress site remotely. Using the WP-CLI, you can perform any action that\u2019s possible in the WordPress admin \u2014 just much more quickly (once you\u2019ve had a bit of practice).<\/p>\n\n\n\n\n\n<div\n\tclass=\"article-cta-shared article-cta-small\"\n>\n    <div class=\"tr-img-wrap-outer jsLoading\"><img decoding=\"async\" class=\"js-img-lazy \" src=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/lazy-loading-transparent.webp\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/article-small-ad-cta-placeholder.webp 1x, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/article-small-ad-cta-placeholder-x2.webp 2x\"  alt=\"Ad background image\" \/><\/div>\n\n\n\n\n  <div class=\"content-btm\">\n    <h2\n      class=\"h2--md\"\n    >\n      Do More with DreamPress\n    <\/h2>\n    <p\n      class=\"p--md\"\n    >\n      DreamPress Plus and Pro users get access to Jetpack Professional (and 200+ premium themes) at no added cost!\n    <\/p>\n\n            <a\n            href=\"https:\/\/www.dreamhost.com\/wordpress\/managed\/\"\n                        class=\"btn btn--white-outline btn--sm btn--round\"\n                                    target=\"_blank\"\n            rel=\"noopener noreferrer\"\n            >\n                            Check Out Plans                    <\/a>\n\n  <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As you get more comfortable developing WordPress, you\u2019ll want some tools that will help you complete your tasks quickly and efficiently. The WordPress admin dashboard is intuitive and comprehensive, but it can also be time-consuming to navigate. What if you want to manage your site more directly, with just a few easy commands? This is [&hellip;]<\/p>\n","protected":false},"author":1062,"featured_media":37959,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_yoast_wpseo_metadesc":"The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. Learn more.","toc_headlines":"[[\"h-an-introduction-to-the-wordpress-command-line-interface-wp-cli\",\"<b>An Introduction to the WordPress Command Line Interface (WP-CLI)<\/b>\"],[\"h-how-to-install-the-wp-cli-on-your-wordpress-website\",\"<b>How to Install the WP-CLI on Your WordPress Website<\/b>\"],[\"h-alternative-ways-to-install-the-wp-cli\",\"<b>Alternative Ways <\/b><b>to Install<\/b><b> the WP-CLI<\/b>\"],[\"h-5-ways-to-use-the-wp-cli-to-manage-your-wordpress-site\",\"<b>5 Ways to Use the WP-CLI to Manage Your WordPress Site<\/b>\"],[\"h-work-more-efficiently-with-the-wordpress-cli\",\"<b>Work More Efficiently with the WordPress CLI<\/b>\"]]","hide_toc":false,"footnotes":""},"categories":[13129,12852,696],"tags":[],"class_list":["post-37942","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developer-central","category-website-design","category-wordpress"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.3 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Introduction to the WordPress CLI - DreamHost<\/title>\n<meta name=\"description\" content=\"The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. Learn more.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What Is the WordPress CLI (And How Can You Use It)?\" \/>\n<meta property=\"og:description\" content=\"The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. Learn more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/\" \/>\n<meta property=\"og:site_name\" content=\"DreamHost Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DreamHost\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-07T15:00:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-22T01:47:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/What-is-WordPress-CLI-Social.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jason Cosper\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dreamhost\" \/>\n<meta name=\"twitter:site\" content=\"@dreamhost\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jason Cosper\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Introduction to the WordPress CLI - DreamHost","description":"The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. Learn more.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/","og_locale":"en_US","og_type":"article","og_title":"What Is the WordPress CLI (And How Can You Use It)?","og_description":"The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. Learn more.","og_url":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/","og_site_name":"DreamHost Blog","article_publisher":"https:\/\/www.facebook.com\/DreamHost\/","article_published_time":"2022-11-07T15:00:21+00:00","article_modified_time":"2025-05-22T01:47:10+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/What-is-WordPress-CLI-Social.jpg","type":"image\/jpeg"}],"author":"Jason Cosper","twitter_card":"summary_large_image","twitter_creator":"@dreamhost","twitter_site":"@dreamhost","twitter_misc":{"Written by":"Jason Cosper","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/#article","isPartOf":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/"},"author":{"name":"Jason Cosper","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/person\/2273b8bf7336df78f6d99a89c17253c4"},"headline":"What Is the WordPress CLI (And How Can You Use It)?","datePublished":"2022-11-07T15:00:21+00:00","dateModified":"2025-05-22T01:47:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/"},"wordCount":1811,"publisher":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/#primaryimage"},"thumbnailUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/What-is-WardPress-CLI-Feature-1.jpg","articleSection":["Developer Central","Website Design","WordPress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/","url":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/","name":"Introduction to the WordPress CLI - DreamHost","isPartOf":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/#primaryimage"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/#primaryimage"},"thumbnailUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/What-is-WardPress-CLI-Feature-1.jpg","datePublished":"2022-11-07T15:00:21+00:00","dateModified":"2025-05-22T01:47:10+00:00","description":"The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. Learn more.","breadcrumb":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/#primaryimage","url":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/What-is-WardPress-CLI-Feature-1.jpg","contentUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/11\/What-is-WardPress-CLI-Feature-1.jpg","width":900,"height":598,"caption":"WordPress CLI"},{"@type":"BreadcrumbList","@id":"https:\/\/www-dev.dreamhost.com\/blog\/guide-to-wp-cli\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dhblog.dream.press\/blog\/"},{"@type":"ListItem","position":2,"name":"What Is the WordPress CLI (And How Can You Use It)?"}]},{"@type":"WebSite","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#website","url":"https:\/\/www-dev.dreamhost.com\/blog\/","name":"DreamHost Blog","description":"","publisher":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www-dev.dreamhost.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization","name":"DreamHost","url":"https:\/\/www-dev.dreamhost.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/dhblog.dream.press\/blog\/wp-content\/uploads\/2019\/01\/dh_logo-blue-2.png","contentUrl":"https:\/\/dhblog.dream.press\/blog\/wp-content\/uploads\/2019\/01\/dh_logo-blue-2.png","width":1200,"height":168,"caption":"DreamHost"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DreamHost\/","https:\/\/x.com\/dreamhost","https:\/\/www.instagram.com\/dreamhost\/","https:\/\/www.linkedin.com\/company\/dreamhost\/","https:\/\/www.youtube.com\/user\/dreamhostusa"]},{"@type":"Person","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/person\/2273b8bf7336df78f6d99a89c17253c4","name":"Jason Cosper","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/02\/IMG_4807-scaled.jpeg","url":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/02\/IMG_4807-scaled.jpeg","contentUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/02\/IMG_4807-scaled.jpeg","caption":"Jason Cosper"},"description":"Jason is DreamHost\u2019s WordPress Product Advocate, based out of Bakersfield, CA. He is currently working on making our DreamPress product even better. In his free time, he likes to curl up on the couch and watch scary movies with his wife Sarah and three very small dogs. Follow him on Twitter.","url":"https:\/\/www-dev.dreamhost.com\/blog\/author\/jasoncosper\/"}]}},"lang":"en","translations":{"en":37942,"de":54087,"pt":54080,"es":54132,"pl":54137,"ru":54141,"uk":54178,"it":68207,"fr":70013,"nl":70046},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/37942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/users\/1062"}],"replies":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/comments?post=37942"}],"version-history":[{"count":10,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/37942\/revisions"}],"predecessor-version":[{"id":61500,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/37942\/revisions\/61500"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/media\/37959"}],"wp:attachment":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/media?parent=37942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/categories?post=37942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/tags?post=37942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}