If you are looking at this article, you’ve probably know what WP CLI is.  If you do not know what it is, let me give you a short introduction about this one.

As you have seen, you can manage your WordPress site using its user friendly Admin end, or through a WordPress API. But what if you don’t want to use any browser or application to do that? What if you want to do it using terminal or command prompt? Well, my friend, WP CLI is here to help you. CLI stands for Command Line Interface. As it name says, you can manage WordPress through command line interface.

To implement this system in Linux based system, you can go over WP CLI official site, and look over the guide. For system, this article can help you. In order to install WP CLI, I recommend you to download a GIT Bash. Using this, you can use git command and Linux command as well.

1st step to do is, download a package wp-cli.phar. You can either use wget or curl to download this file, or you can directly download it from here.

Lets open GIT Bash, and run following command.

After you enter this command, it will start downloading this phase, in your current directory. After its completed, search for wp-cli.phar file

Browse to the directory that has wp-cli.phar file and try this command

if you have php command installed in your environment variable, you will see some output. Otherwise, you will get something like command “php” not found.

Now, you don’t want wp-cli.phar to be a command. So lets make it just wp. In order to do that, you need to give the permission to be executable. You do this by using chmod command

Now open the explorer and move wp-cli.phar to some directory. As for me, I have moved this file to C:\wamp\bin. And rename wp-cli.phar to wp (there won’t be any extension; just wp).

We are almost there. Now you need to register wp as an command. So, you need to add it in environment variable. To do so, go to My Computer Properties -> Advanced system settings > Environment Variables.  Now, search for variable “Path” and add directory where you have saved renamed file of wp-cli.phar like this:

Remember, before you add this string, you need to add semicolon so that operating system knows this one is a separate path. So, you string would look something like this:

After you are done, restart your PC. And again, open your git bash and try command wp, and hit enter. You won’t get error like “wp” not found. This indicates, you have done setting up WP CLI in your computer.

 

Final note: In order to use this command, you need to change your directory to your WordPress Project. For example, if you have your project setup inside C:\wamp\www\wp\ you need to be in this directory in your terminal. Otherwise, the command cannot identify which WordPress site you want to manage.

To know more about commands, browse to the official site of WP-CLI

Share:


About the Author



Leave a Reply

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

Premium WordPress Themes