Questions tagged [wp-cli]

WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.

Filter by
Sorted by
Tagged with
43 votes
4 answers
37k views

How to change user password with wp-cli?

wp-cli is great. But it's not clear how I can quickly change a user password with it. How to change a user's password programatically can probably help to figure this out. Although wp user ...
the's user avatar
  • 1,397
29 votes
2 answers
11k views

Detect if WP is running under WP-CLI

I use the wonderful WP-CLI tool. Due to dependence on Apache environment variables for a specific use case, I need to enable a bit of code to run only when running under WP-CLI. How can I detect if WP ...
dotancohen's user avatar
28 votes
6 answers
13k views

Running WP Cron on multisite the right way

I have WordPress Multisite with several sites. I set up DISABLE_WP_CRON to true in my wp-config.php. If we set up cron task with wget or curl we have 30 sec rule to execute PHP script. It's so small ...
Kolya Korobochkin's user avatar
26 votes
8 answers
25k views

WP CLI "Error establishing a database connection" in localhost (MAMP)

I get this error when I try to create something with WP CLI: Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is ...
Klevis Miho's user avatar
23 votes
4 answers
8k views

how to update serialized options programatically?

I want to automate updating plugin options. There are some things that I repeat a lot. With wp-cli I know I can update simple options like this: php wp-cli.phar option update blog_public 1 However, ...
lalo's user avatar
  • 521
16 votes
3 answers
3k views

How I prevent a plugin to be loaded when doing WP-CLI?

I currently use this code in the main plugins file itself. But that plugin is not my own so I would prefer to be able to upgrade it normally without every time adding this code. if ( defined( 'WP_CLI'...
NextGenThemes's user avatar
15 votes
1 answer
3k views

Fastest way (least amount of steps) to locally import a remote database using WP-CLI

I'd like to automate the task of importing a remote database using the WP-CLI. The current process is to ssh to the server, and run an export to file using WP-CLI, copy the file to a local directory ...
jgraup's user avatar
  • 9,699
14 votes
4 answers
13k views

WP-CLI - Selecting PHP version

On a development server I have a co-install of PHP 5.6 & 7; nginx is configured with PHP 5.6. When I type "wp" it returns several errors and at the end of the error is a message containing the ...
j03's user avatar
  • 167
12 votes
2 answers
2k views

WP-CLI not recognizing commercial plugin updates

I'm running into an issue I haven't encountered before where WP-CLI is not recognizing plugin updates for commercial plugins. The plugin updates appear in my WordPress dashboard, but running ../wp-...
NateWr's user avatar
  • 772
11 votes
1 answer
1k views

Why is it important to deactivate a plugin before deleting it?

I stumbled across this page, where it says that wp plugin delete does this: Deletes plugin files without deactivating or uninstalling. Why is it important to deactivate a plugin before it is deleted? ...
Zeth's user avatar
  • 828
11 votes
3 answers
4k views

wp-cli Enabling Maintainance Mode

During theme or plugin upgrades, maintenance mode is enabled and then disabled once complete. Is it possible to manually enable / disable maintenance mode? Enabling Maintenance mode... Downloading ...
Miati's user avatar
  • 213
10 votes
1 answer
8k views

How can I bulk delete media and attachments using WP-CLI?

I'm trying to mass delete 4000 images in a wordpress website. WP itself sets the max to 999, which would work fine and take a few minutes to delete them via the backend. However, I get REQUEST URI TOO ...
user658182's user avatar
10 votes
4 answers
3k views

Is there a drush equivalent for WordPress yet?

I'm working with Drupal on a project right now, and for all its faults, having a command line interface like drush to the Drupal framework is a godsend. Is there an equivalent for using WordPress to ...
Chris Adams's user avatar
9 votes
2 answers
6k views

How to change user_login with wp-cli?

How to change the username with wp-cli? This does not work: wp user update old_login --user-login=new_login
the's user avatar
  • 1,397
9 votes
3 answers
6k views

How can I batch delete all unattached images with WP-CLI or other automated process?

After using WPML Media, a plugin that creates duplicates of each image for each language, we now have almost 100,000 duplicate images that we're not going to use and need to get rid of. We need to ...
user658182's user avatar
9 votes
1 answer
6k views

How do I run a PHP script from Wordpress environment, like `wp shell`?

wp shell is a very useful tool that lets you run PHP statements and expressions interactively, from within a Wordpress environment. It lets you use all the functions, classes and globals that you can ...
Flimm's user avatar
  • 674
9 votes
4 answers
9k views

wp-cli displays php notices when display errors off

I am using wp-cli and I am having php notices and errors show up when running wp-export. Some of these warnings and errors are ending up in the output file. How can I force errors to NOT show up. I ...
Chris Muench's user avatar
8 votes
1 answer
3k views

Using wp-cli can I not query pages by their title?

All of these do the same thing: wp post list --post_type=page wp post list --post_type=page --post_title=dfdsfds wp post list --post_type=page --title=sdfdsf How can I query the post by the title? ...
Kit Sunde's user avatar
  • 371
8 votes
1 answer
681 views

wp-cli 0.14.1 MySQL error

I just updated to wp-cli 0.14.1 today and once again having a MySQL issue. I'm on Windows, Wampserver, and Cygwin. When I first updated to the last rev (0.14.0) I had a similar problem and wound up ...
user1640896's user avatar
7 votes
4 answers
3k views

WP-CLI Cannot Connect to Database due to Vagrant

I am running the most recent version of WP-CLI on my mac. I do all WordPress development within Vagrant, but would like to run WP-CLI commands in the host machine. I have a domain alias from "dev....
Zach Russell's user avatar
  • 1,043
7 votes
3 answers
9k views

How to use wp-cli.yml file?

I am trying to set up a wp-cli.yml file but every time I run the command, the file is ignored. Where should the file be located? And how should I call the command to use it? I tried having a file in ...
gdaniel's user avatar
  • 3,233
7 votes
2 answers
3k views

Changing the WP CLI cache folder

As a highly concerned hosting company owner I am using WP-CLI to update plugins, themes and wp core of my clients. Updating WP-Core find /home/*/public_html -name "wp-admin" -execdir /home/wp core ...
Luka's user avatar
  • 213
7 votes
2 answers
2k views

WP-CLI Process Killed

I have around 1200 large images which I'd like to regenerate. I'm using the WP-CLI command wp media regenerate. After around 61 images are generated, the terminal shows the message Killed. Why is ...
Sam's user avatar
  • 2,106
7 votes
1 answer
1k views

Wordpress test environment on windows

I'm new to TDD and want to set up a test environment for my wordpress plugin. I was able to find a sample plugin from wp-cli with the very useful script. It was very easy to write the first test ...
No3x's user avatar
  • 193
6 votes
3 answers
4k views

How do I clone or duplicate a post with the WordPress Command Line Interface WP-CLI?

I know that I can clone or duplicate a post with several plugins. The one I use most often is https://wordpress.org/plugins/duplicate-post/. However I am using the WP-CLI more and more lately and I ...
tfrangio's user avatar
6 votes
1 answer
10k views

Run WP-CLI using PHP

I've installed WP-CLI on the Mac and my next step is to execute WP-CLI commands using PHP script. I've tried to implement it the following way but I do not see anything happening. Can someone please ...
WKL's user avatar
  • 63
6 votes
1 answer
3k views

How to update an 'array' option using wp-cli [duplicate]

I'm trying to write a bash script to automate the syncing of a live site to a dev site. I have the basics figured out, like exporting the production db and importing / updating urls in the dev site, ...
passionsplay's user avatar
6 votes
1 answer
4k views

WP-CLI get all posts from certain post type and taxonomy term

I am trying to select all the posts from certain post type and term in custom taxonomy, but what ever I try gets me just the list of all the posts in certain post type wp post list --post_type=custom-...
dingo_d's user avatar
  • 1,919
6 votes
2 answers
3k views

wp-cli commands do nothing, return nothing

I'm using wp-cli 1.5.1. My server is running php7.2. I'm not running suhosin. (Some people seem to think that suhosin may cause the same symptom) When I issue wpcli commands within a non-wordpress ...
bob's user avatar
  • 237
6 votes
1 answer
10k views

wp-cli doesn't find and wordpress installation

I wanted to try wp-cli, downloaded the phar and installed it by moving it to ~/bin which is in my path. Then wp --info works, but maybe shows insufficient information. (e.g. no php path, though it is ...
step21's user avatar
  • 63
6 votes
1 answer
13k views

WP cli --path does not seem to work

WP-cli does not seem to work when adding a --path param me@host:~$ wp plugin status --path=`/home/me/domains/example.com/public_html` -bash: /home/me/domains/example.com/public_html: is a directory ...
janw's user avatar
  • 998
6 votes
1 answer
1k views

Does wp post delete also delete metadata associated with posts?

say this: wp post delete --force $(wp post list --post_type=product --format=ids) I found out that it's far more fast and performant than deleting posts from admin. But I was wandering: any ...
Luca Reghellin's user avatar
6 votes
2 answers
1k views

Enable Auto-updates for all plugins using wp-cli? (since wordpress 5.5)

Since WP 5.5 just released and now you can set plugins to auto-update, can this be done via wp-cli? Looking at the documentation, I don't see a sub-command for it: https://developer.wordpress.org/cli/...
Alexnl's user avatar
  • 307
5 votes
1 answer
1k views

WP-CLI update date and time format

I'm new to WP-CLI. After a lot of Googling and searching in this forum, I haven't found out which is the command to update both date and time formats. wp option update...... Thanks for any help! ...
Roberto Jobet's user avatar
5 votes
3 answers
5k views

How to use command 'wp post create' in wp-cli properly?

I need to create a single post with title, content and excerpt with this command as it's described in the utility documentation. Could you please show me an example of how to use it? I couldn't find ...
Sergei Basharov's user avatar
5 votes
1 answer
1k views

How do I activate an mu-plugin with WP-CLI?

Do I need some extra WP-CLI bundle to activate mu-plugins via command line? I can't find anything about that in the docs. Are mu-plugins treated differently by WP-CLI? I created /wp-content/mu-...
leymannx's user avatar
  • 3,041
5 votes
1 answer
401 views

How to create a WP-CLI command with $_POST?

I would like to create a WP-CLI command for WordPress Database Reset plugin. In the main function it uses $_POST for the options but when running the command in cli they will not exist. How should ...
grappler's user avatar
  • 825
5 votes
2 answers
2k views

WP-CLI - Return posts with matching meta key

I am using the WP-CLI to manage my sites. I can run the following command wp post list --fields=ID,mycustomfield ID | mycustomfield ----------------------- 1 | active 2 | active 3 ...
fightstarr20's user avatar
  • 1,107
5 votes
3 answers
3k views

Is it possible just by using wp-cli to migrate one multisite instance to single site?

It took me great time today to convert one site from https://example.com to https://sub.example2.com from WordPress multiste installation to normal WordPress installation (read: singlesite). Since I ...
prosti's user avatar
  • 4,243
5 votes
1 answer
1k views

WP-CLI :: Cannot installing plugin as www-data

Just started using WP-CLI and instead of running with --allow-root, decided to run as www-data user. Things are good so far but cannot install any plugin that way at all: root@wp-ks320:/var/www/ks320#...
MacUsers's user avatar
  • 151
5 votes
2 answers
1k views

How to reset passwords for all users on a network using wp cli

I have a WP Network (sub directory), Sometime specially in case of security emergencies, it is generally preferred to change passwords for all users. I am looking for a way to reset passwords by ...
patilswapnilv's user avatar
5 votes
1 answer
631 views

WP-CLI methods for get_current_blog_id, get_blog_details or $wpdb->prefix

I'm looking for some extra information about an mu site (--url) when attempting to export from a remote server to my local testing environment. One requirement for migration is the existing blog_id ...
jgraup's user avatar
  • 9,699
4 votes
2 answers
6k views

WP-CLI Bulk delete posts from specific category

I would like to know how to bulk delete posts from a specific category using the WP-CLI, any tip?
abaporu's user avatar
  • 143
4 votes
3 answers
4k views

Can I create multiple pages at once using WP-CLI?

I am new to WP-CLI and having trouble finding examples of what I want to do. I know how to create a single page. wp post create --post_type=page --post_status=publish --post_title='Contact' Is ...
JAstuccio's user avatar
  • 141
4 votes
2 answers
2k views

How do I set and list page_template with wpcli?

I have a page that has a new template, and I want to set that new template with wp-cli. When I wp post get <id> I get an output like the following: +-----------------------+--------------------...
Mike Lyons's user avatar
4 votes
3 answers
254 views

Disable comment windows for all existing posts (pages/blogposts)

Is there a WP-CLI command to disable comment windows for all existing posts (pages/blogposts)? I ask this since when I change a theme for a site I have, all pages in that site getting their comment ...
Arcticooling's user avatar
4 votes
1 answer
564 views

wp media regenerate unknown --image_size parameter

It is said in the documentation that we can set the --image_size parameter to regenerate all images for only this size. However, I am getting this for this command: Error: Parameter errors: unknown -...
Igor Skoldin's user avatar
4 votes
1 answer
1k views

How can I run a WP-CLI command as authenticated user?

I've written a command for wp-cli called wp nurse. It is styled after the wp doctor command, except is meant to run the WordPress Site Health checks. Using the in-browser tool, all 16 tests currently ...
Lucky The Rabbit's user avatar
4 votes
1 answer
489 views

Difference between deactivating, uninstalling, and deleting plugins

I understand the difference between deactivation and uninstallation. But the CLI also has a delete option. How does it differ? To be safe, should I deactivate, then uninstall, then delete?
lonix's user avatar
  • 301
4 votes
2 answers
4k views

"Could not open input file" error even when WP-CLI is in the path

I'm developing Wordpress locally with XAMPP, and currently trying to install the WP-CLI tools as described here using Cygwin. I renamed wp-cli.phar to wp, made it executable and moved it to the ...
Hashim Aziz's user avatar

1
2 3 4 5
8