How to set WordPress configuration variable using wp-cli

How to set WordPress configuration variable using wp-cli

Are you still relying on the File Manager in your cPanel to tweak configuration variables for your WordPress website? It's time to step into 2022! Nowadays, most hosting providers, including popular cloud hosting platforms, offer secure SSH connections to your WordPress site or server. Take Cloudways, for instance—they provide a comprehensive solution for WordPress website management. But let's get back to the core focus of this article.

In this post, I'll be sharing a valuable tip specifically for WordPress owners and developers: how to effortlessly configure your WordPress settings using the wp-cli command.

wp-cli, is a powerful tool designed to simplify WordPress site management through the command line. Whether you're a WordPress owner or developer, wp-cli streamlines tasks like updating configuration variables, making your workflow more efficient. Best of all, wp-cli is both free and open-source, and it can be easily installed on any WordPress site.

what is wp-cli

Required Tools:

- SSH Access to Server
- wp-cli should be installed
- SSH Client / Terminal

Before we can set WordPress configuration variables using wp-cli, we need to install it on our server. Installing wp-cli is easy and can be done in just a few steps.

Step 1 : Lets start by downloading wp-cli
step 1 install wp-cli
Step 2 : Make the file executable with the following command:
step 1 install wp-cli
Step 3 : Move the file to a directory in your PATH for easy access using the following command:
step 3 move the file to path
Step 4 : Now we are ready to issue wp-cli commands
But first lets checkout if the installation succeeded. lets run this command : wp --version
step 4 verify installation
Step 5 : Now that we verified that wp-cli installation succeeded
Lets try updating some configurations from wp_options table. Lets try running this command : wp option update posts_per_page 11
step 5 run some commands
Step 5.1 : We can also update environment variables
We can also update environment varilables. For example the WP_DEBUG environment variable . Setting this environment variable to true is useful when debugging WordPress website. Lets try running this command : wp config set WP_DEBUG true --raw
set environment variable

Thats it!

Setting WordPress configuration variables using wp-cli is a quick and easy process that can save you time and hassle.
By using wp-cli, you can manage your WordPress site from the command line, making tasks like updating configuration variables much easier.I hope this article has shown you how to set WordPress configuration variables using wp-cli, step-by-step.

Facebook
Twitter
LinkedIn