How to install WP CLI in Windows

What is WP CLI?

As part of my experience working on WordPress since 2009, which counts as more than 14 years, one of the working tools I would recommend to new WordPress developers is WP CLI.

So what is WP CLI? It’s a command line interface that allows developer to manage their WordPress sites using command prompt, if you are using Windows or Terminal if you are using Linux.

One of the commands that is useful(to me at least) is when I clean up thousands of spam comments without using bulk action, which is limited to 25 posts deletion per request. Not to mention that would be time-consuming. A single WP CLI command will do this once in under 1-3 seconds.

$ wp comment delete $(wp comment list --status=spam --format=ids)

How to install WP CLI?

While I recommend developers use Linux-based operating systems for their workstations, some of us still find Windows as our main operating system. This tutorial will walk you through installing WP CLI on Windows.

The first thing I would recommend is that we avoid using Windows default command prompt and instead use git-scm. Download and install https://git-scm.com/download/win first. We will use this command interface for the rest of our work.

Second, we need to install Composer. Download Composer-Setup.exe which will give you the latest Composer version, then we need to setup Composer in our Windows PATH. This will let you use composer command from any directory. Verify if your composer installed properly by using using the following command:

$ cd C:/
$ C:/ composer -V

Once you’re done, create a new directory in C:/, depending on what drive letter your Windows is using. It should be using C:/ as default but double-check your local install. Download https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar and save it in our new directory. Now using Visual Editor IDE or anything you are comfortable with, create a new batch file and name it wp.bat for our alias.

Save the following code on your wp.bat file:

@ECHO OFF
php "%~dp0wp-cli.phar" %*

Set the variable Path in your local environment. Go over to System Properties -> Advanced System Properties -> Advanced. Click on the Environment Variables under the System Variables and find the variable name Path. Add ;C:\WP-CLI and click save. Restart the bash interface you are using at the moment and type wp cli version.

If you can see WP-CLI 2.x.x, then it means you have successfully installed WP CLI.

Happy coding!


  • Contributor Highlights v1.1.0 Released

    I’m excited to announce that Contributor Highlights has been updated to version 1.1.0. This release introduces new badges, resolves dependency issues, and improves layout alignment for a smoother and more consistent experience. ✨ What’s New Why This Update Matters My goal for Contributor Highlights is to continuously evolve alongside the WordPress community. The new badges…

  • Chronicle Journal Theme Demo Now Live

    I’m happy to share that the Chronicle Journal theme demo site is now live at chronicle-journal.rollybueno.com. Chronicle Journal is a modern, editorial-style WordPress theme built for writers, storytellers, and publishers who want a timeless and focused reading experience. It’s designed around clean typography, balanced layouts, and subtle spacing that lets your words take the spotlight.…

  • Joined WCUS 2025 Contributor Day Remotely – Hosting Team Wins

    This year I got the chance to join WordCamp US 2025 Contributor Day remotely, and I’m really happy to share that I was able to contribute to the Hosting Team. Even though I wasn’t there in person, it honestly felt like being part of the action. The collaboration, support, and energy from everyone made it…

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *