Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

12
votes
4answers
3k 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, ...
10
votes
1answer
912 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 ...
15
votes
4answers
4k 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 ...
11
votes
2answers
9k 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 ...
4
votes
1answer
1k 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 ...
3
votes
3answers
5k 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 ...
1
vote
2answers
624 views

Utilize WP-CLI from inside WordPress, not SSH

I'm looking for a way to test out some WP-CLI commands but from the Debug Bar Console where I normally test PHP. For cases when I don't want to switch windows to SSH, this might be a way to reuse/...
4
votes
1answer
3k 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 ...
3
votes
3answers
884 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 ...
2
votes
1answer
157 views

Execute wp-cli command on all sites on server

Im pretty sure someone knows the answer, i'm trying to find a way to execute wp cli commands to all sites on my server. So my directory structure is /srv/users/serververpilot/apps/*/public The ...
1
vote
2answers
902 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: +-----------------------+--------------------...
3
votes
0answers
208 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 ...
2
votes
1answer
2k 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?
1
vote
1answer
1k 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 ...
1
vote
1answer
686 views

How can I replace all regex matches using the WP_CLI search-replace tool

With WP CLI I can use the search-replace method like this: wp search-replace 'foo' 'bar' However, when I use regex, it only replaces the first occurrence within each DB field: wp search-replace '...
1
vote
2answers
84 views

Is it possible to use WP-CLI via PHP-framework?

I have Zend framework 2 application (PHP), via which I want to use WP-CLI functionality. near Zend project I have WordPress project, which I want to maintain from Zend via WP-CLI. I see in the docs ...
0
votes
1answer
81 views

Trying to install Wordpress on WSL Windows 10, and running into issues with wp-cli and “wp db create”

Okay so I'm following this tutorial: https://hellojason.net/blog/how-to-setup-wordpress-locally-on-windows-subsystem-for-linux/ I had to do a bunch of monkey around to get MySQL to work because for ...