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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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.

2
votes
3answers
494 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 ...
2
votes
3answers
1k 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 ...
1
vote
1answer
17 views

wp-cli: For development, how can I activate a theme that is on the local disk but not zipped?

I am developing a WP theme which I'm referring to as foobar for the sake of this question. It's located in /var/www/html/wp-content/themes/foobar. At the moment, I am activating it via wp-admin ...
-1
votes
0answers
15 views

How to run php script on separate wordpress installs?

I made a simple command line php script to create posts. I would like the script to create posts on separate wordpress installs on the same server. Right now i just copied the script to both wordpress ...
0
votes
2answers
26 views

WP CLI can't delete plugin related table

I have installed a plugin following wp plugin install ... CLI command and then activate through CLI command its working properly. But problem is that when I deactivate then delete the plugin the table ...
-1
votes
1answer
45 views

Install WordPress using PHP

I just want to download, install and setup WordPress using PHP. I can do it using WP-CLI and command line and it worked. Now I want to do it using with WP-CLI and PHP. I read Run WP-CLI using PHP ...
1
vote
1answer
730 views

WP CLI not importing media files

When I tried on localhost, it appears media files are imported. When I tried on real server (AWS LightSail) seems like images are not imported why might it be? I did not ask it to --skip The main ...
2
votes
1answer
48 views

Safe to set permissions to 757 temporarily to update via wp-cli?

LEMP stack on digitalocean VPS. I haven't been able to get "wp core update" to work unless public (or "Other") has execute permission, i.e. 757 or 777. Otherwise, it throws "Error: Could not create ...
1
vote
0answers
30 views

wp core install database connection error

I am new to wordpress but not to programming to please bear with me. I am trying to get a new wordpress project up and running locally using the wp-cli. But when I run the following command: wp core ...
1
vote
1answer
28 views

Lock User and Enforce Password change via wp-cli

Via wp-cli I want on automated installation scripts to either: "lock" and send an email to enforce to follow a "forgotten password" link via a custom email. Enforce a user on first login to change ...
0
votes
1answer
37 views

Userless db-only wordpress instalation

Hello how I can perform a wordpress installation without the need to create users. I want to just run a command and just install the database. I want the user to get installed via gui when cli install ...
1
vote
1answer
18 views

Allow download_url for lan addresses

I'm hosting a wp site on my own server (at home) and I would like to use wp cli to import media from my own computer. On my computer, I have a web server and I asks to wp-cli to import media from "...
0
votes
1answer
23 views

WP Cli - post add meta in xargs after wp post generate - add multiple fields

This command will generate posts and create a field with key "bar" and value "foo" wp post generate --format=ids --count=10 | xargs -d ' ' -I % wp post meta add % foo bar This does not seem to work: ...
1
vote
0answers
28 views

How to use wp db export and import together?

When I use WP-CLI I'm having some issues with the wp db export and wp db import commands. I have a local site on my desktop that I would like to migrate to my laptop so I can work on it. So I go on ...
0
votes
1answer
159 views

Bulk remove custom post type and its attachments with wp-cli?

I have a custom post type called "meetings" and I will like to bulk remove all the posts and all of its attachment images... Can this be done with the wp-cli? thank you!
0
votes
4answers
236 views

What's the proper way to setup WP-CLI on Ubuntu so that I don't have to use the flag --allow-root?

I have an Ubuntu server, typical LAMP stack with default www-data as the user / group under which Apache serves files. When updating with WP-CLI I always have to type --allow-root flag. How do I ...
0
votes
0answers
16 views

Limit a user only to wp-cli only use

I have developed a docker wordpress solution and it uses wp-cli to do the required installation from shell. The installation itself required a user to get generated therefore I create a default admin ...
0
votes
1answer
35 views

Automate WordPress website setup with prefilled data

I'm asked to write documentation explaining how to set up a website to run exactly as the live environment does right now. The website is dependent on WPML, certain categories and menu's being ...
0
votes
0answers
25 views

How to get WP-CLI to work with bash scripts?

I have wp-cli installed on a WHM/cpanel server running multi-php versions with EasyApache4. I am able to use wp-cli when Im either in the directory where wp-config resides or I use the –path command ...
0
votes
0answers
20 views

Updating category ID using wp cli search-replace

I was wondering if search-replace using the old ID and the desired ID will work on a category and its relations. In order to avoid conflicts, would it be better to limit this at specific tables? I ...
0
votes
0answers
20 views

How come there is no error if I upgrade WordPress core after locking .htaccess permissions to 644?

How come there is no error if I upgrade WordPress core after locking .htaccess' permissions to 644? I upgrade WordPress this way basically: wp plugin update --all wp core update wp language core ...
0
votes
0answers
10 views

WP CLI Update Payment Gateway Settings Doesn't Save

I can enable payment gateways with below command: wp wc payment_gateway update paypal --user=1 --enable=true path=/www #This works well However, when I try to update a setting of the gateway, it ...
8
votes
4answers
2k views

Is there a drush equivalent for WordPress yet?

I'm working with Drupal on a project right now, and for all it's faults, having a commandline interface like drush to the Drupal framework is a godsend. Is there an equivalent for using Wordpress to ...
-1
votes
3answers
709 views

MAMP PRO WP-CLI Error: Error establishing a database connection

I followed the install instructions at wp-cli.org and am unable to connect to database. I am using a newly installed (this morning) version of MAMP PRO. which php /usr/bin/php echo $WP_CLI_PHP /...
1
vote
1answer
49 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 ...
5
votes
2answers
404 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 ...
1
vote
0answers
20 views

What could cause WP-CLI search-replace to not replace all instances of a string?

We're migrating a site from dev to production using wp-cli to replace all occurrences in the database for the url, just like in the search-replace example. (http://example.dev to https://example.com) ...
8
votes
3answers
325 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'...
0
votes
0answers
33 views

WP-CLI - How to install a plugin from a remote server

I'm trying to install a plugin that i downloaded and i host on my server inside a vagrant box to use locally. I'm running this command to try to install it: wp plugin install https://example.com/...
3
votes
2answers
47 views

Revert WordPress default options after a PHPUnit test has run

tl;dr: is there a way to make changes to WordPress options during a PHPUnit test suite execution, and have the changes reverted to the WordPress defaults before the next test suite is executed, ...
0
votes
1answer
24 views

How to destroy all user sessions via WP-CLI

In installed WP-CLI v1.5.0 I ran wp --info and it return the correct info. I then ran wp user session destroy user1 --all and got this: CORRECT>w user session destroy prvweb -all (y|n|e|a)? ...
3
votes
3answers
4k 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 ...
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 ...
1
vote
1answer
186 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-...
4
votes
3answers
109 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 ...
0
votes
1answer
71 views

Why doesn't 'wp' command work in my WP-CLI installation?

The wp-cli.phar file is in the same directory from where I test the wp command. But it says the command doesn't exist. When I'm trying to see if WP-CLI is installed with the php wp-cli.phar --info ...
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 ...
1
vote
2answers
789 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: +-----------------------+--------------------...
0
votes
1answer
107 views

Update the permalink for one post via wp cli

I'm using WP-CLI to import articles from a non-WordPress system. The legacy system has a custom URL defined for every post. I'd like to be able to set the permalink on the posts I'm importing base on ...
0
votes
1answer
19 views

Do all WordPress installations include WP CLI by default

Does the standard WordPress installation include WP CLI? So if someone install WordPress on their website does it automatically include WP CLI?
0
votes
0answers
19 views

Unable to import complete data remote wp-cli wordpress

I wanted to make process of wordpress site migration automate everything works fine but i am unable to import complete site from remote to local.Might be something wrong in code, any help will be ...
1
vote
2answers
112 views

PHPCS: Strings should have translatable content

I am validating plugin to make it compatible with WPCS. a function which contains gettext placeholder returning error when i run phpcs command. Source code and screenshot of error is attached for ...
9
votes
1answer
785 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? ...
0
votes
0answers
34 views

Warning Message is get displayed after executing wp-cli command using linux crontabs

I wanted to update WordPress core version and all plugins every week, so for this I install WP-CLI on my WordPress installed server. So, for doing this I wrote wp-cli command in Linux shell script as ...
0
votes
1answer
20 views

WP-CLI plugin delete command fails silently

I have just started trying out WP-CLI and did a basic test of installing a plugin. It installed fine, no issue. However, the plugin delete command fails silently, with no error messages and the ...
0
votes
2answers
65 views

A shorter way to automatically update WordPress?

This is how I started to update WordPress daily: cat <<-"CRON_DAILY" > /etc/cron.daily/nses_cron_daily for dir in /var/www/html/*/; do cd "$dir" && /usr/local/bin/wp plugin ...
1
vote
1answer
128 views

Error updating WP-CLI

Below is the output from my attempt to update wp-cli on Windows 10. Clearly another version is available. Can someone please explain how to make this work? C:\Users\HP>wp cli update Error: You can ...
4
votes
1answer
28 views

What is the difference between the Package Language and the Site Language?

What is the difference between the Package Language and the Site Language? If I run: wp core language list I get: en_AU | English (Australia) | English (Australia) | active | available If I run: ...
1
vote
3answers
1k 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 ...
0
votes
0answers
26 views

Moving Featured Images

I have been moving around 40k posts from one site to another (different domains), using wp cli, all went well, but it seems the featured image weren't imported. I have now uploaded all media files ...