Stack Exchange Network

Stack Exchange network consists of 175 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.

4
votes
3answers
5k 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 ...
1
vote
1answer
87 views

How to prevent WP-CLI shell from exiting when an exception occurs?

I am using WP-CLI shell to quickly debug some code, but every time I run into a fatal exception (e.g. undefined constants/functions) the shell exits and I lose my shell session. Is there a way to ...
2
votes
1answer
34 views

Need MySQL Query or WP-CLI command to updates old URLs in Shortcodes [closed]

My client's website is moved from http to https, and I have updated most of the URLs using queries in phpMyAdmin, but I have been unable to update shortcode URLs. I have used the following query to ...
0
votes
2answers
734 views

WordPress API - count posts

Is there a way to count the number of posts / pages via the WordPress API? I'm wanting to insert a post then check, using the API, that the count has gone up by 1. I've looked at http://codex....
1
vote
1answer
391 views

Error when setting up phpunit tests with wp-cli scaffold

I am trying to figure out the setup for unit tests for wordpress plugins. I am using Ubuntu. So far I have: Local WordPress Installation WP-CLI up and running Installed phpunit used wp scaffold ...
1
vote
1answer
166 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 ...
3
votes
1answer
147 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 ...
4
votes
1answer
43 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 ...
0
votes
2answers
375 views

How to update WP-CLI on Windows via Composer?

I installed wp-cli back in April on my Windows box using composer. I believe with the following command: composer create-project wp-cli/wp-cli --no-dev as outlined in the alternate install methods on ...
1
vote
2answers
25 views

Removing a wordpress multisite installation and preserving the database before migrate to nginx

I have a WordPress multisite installation, and I need to remove the multisite, and keeps just the site ID 5 (domain.com/br) in the main address (domain.com). So I follow this tutorial to remove ...
1
vote
0answers
21 views

Overwrite media matching post title using WP CLI's media import command

I am trying to overwrite a media post using the WordPress CLI. The wp post create --post_type=attachment command can create an empty media item, but cannot attach an image file through WP-CLI. This ...
0
votes
1answer
16 views

Creating a subcommand for custom wp-cli command

I'm toying around with writing custom wp-cli commands. I have successfully created a simple command, wp-cli theme save which runs a script to backup the site's theme files: <?php class ...
0
votes
1answer
17 views

Adding content from file with wp post create

I thought I had seen something like this documented where you could pipe in content to a wp-cli arg like so: wp post create --post_type=page --post_title="Blah" --post_content= < content.txt I ...
7
votes
2answers
584 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-...
1
vote
1answer
27 views

WP-CLI How to generate a list of posts with corresponding meta values

I created this SQL query to generate a list of posts (which I will use for a CSV Sheet) SELECT p.ID, p.post_content, p.post_title, pm1.meta_value as 'Amazon.com', pm2.meta_value as 'Amazon.co.uk' ...
2
votes
2answers
174 views

Can I create (or update) user password with WP-CLI by hash?

I want to make a user-create snippet, but it must not includes plain password. $ wp user create username username@example.com --role=administrator --user_pass=password So can I create (or update) ...
0
votes
1answer
755 views

PHP warning are displaying when using WP CLI

I'm running WP CLI 0.25.0 on Debian, PHP 7.0. I keep getting the PHP warnings displayed. In php.ini used for cli I have set error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING ...
0
votes
2answers
456 views

WP-CLI wp theme install url PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature

I tried use wp-cli theme install with option url from my dropbox link. But unfortunately, I got this problem: PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature This ...
0
votes
1answer
29 views

Set Site Icon programmatically (eg. using `wp cli`)

Wordpress has a "Site Icon" feature that serves correctly-sized favicons and so on to browsers. Is there a way to drive this feature programmatically, eg. by uploading media and setting an option with ...
0
votes
0answers
18 views

Sync users from production and development environments using wp cli

I want to sync users registered at production environment to development environment. Using the below command sequence for this: 1) Find max user id at the target dev environment using: wp ...
1
vote
4answers
1k views

WP CLI Shell not working on Windows

I recently installed WP-CLI on windows with the instructions below. However when I type wp shell I get en error: The system cannot find the path specified. One solution on github says: Psysh is not ...
-2
votes
1answer
73 views

How to 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-...
0
votes
1answer
39 views

WP CLI - show users whose ID is larger than given ID

The below code achieves what i need for given ID = 200. wp user list --role='customer' --orderby=ID --order=asc | awk 'FNR == 1 {next} $1>200 {print ;}' How to do it with wp user list and WP ...
1
vote
3answers
1k 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 ...
0
votes
1answer
31 views

WP-CLI --meta-input error: Warning: Invalid argument supplied for foreach()

I'm using this code to import posts from a csv file, which works great except for the meta_input (custom fields) while IFS=$'\t', read -r col1 col2 col3 col4 col5 col6; \ do \ wp post create \ --...
0
votes
1answer
24 views

Is WP-CLI safe to use in a hosting environment? Why?

Beginner question. I am learning to use WP-CLI and I am trying to understand how/why it's safe to use. Are there any security measures I need to take when adding it to a hosting environment?
1
vote
2answers
1k 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
48 views

PHP if statement with German umlauts [closed]

Im sure someone can help here pls. I have an problem with German Umlauts (ä,ü,ö) Code $wppost_interpret = $this->data['track']['itunes']['artistName']; $wppost_interpret_title = $this->data['...
4
votes
3answers
122 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 ...
15
votes
3answers
11k 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 ...
1
vote
1answer
155 views

What tools respect `.distignore`?

You can create a plugin using the wp scaffold plugin PLUGINNAME command. It creates a bunch of files, including .distignore, .editorconfig, .gitignore, .travis.yml. Here is the contents of ....
0
votes
0answers
26 views

Blank character set with WP-CLI

On one of our servers, WP-CLI seems to be convinced that the character set must be an empty string. $ wp db cli mysql: Character set '' is not a compiled character set and is not specified in the '/...
0
votes
0answers
11 views

remove roles from multisite users but retain post attribution?

I work with a large multisite that uses a plugin that allows LDAP authentication. We would like to clean up roles for users who are now longer have accounts in Active Directory, just to keep things ...
0
votes
1answer
74 views

Wordpress speed slow after .5 million single image post via wp-cli

I am trying to Creat Wordpress website that will contain 10 Million post, such that when i upload a single its become a post with it's own name as title. and i am importing these images with Wp-cli. ...
0
votes
0answers
27 views

Exporting CPT from dev site and import into live site?

Trying to figure out the best way of doing this with the WP CLI. Right now I'm running: wp export --dir=./tmp_posts/ --post__in=2656 --with_attachments This creates an export file, but some of the ...
0
votes
0answers
31 views

Attachments failing to import with WP CLI

So I'm transitioning a site to a new server and doing a redesign. I used the wp cli tool to export from the old site and import into the new. For some reason, a lot of the images failed to import, ...
0
votes
1answer
747 views

wp-cli: Error establishing a database connection: undefined constant DB_USER

Bringing this over from the wp-cli github page. I've been searching here, the docs, and the webs for several hours. Currently hosting with Blue Host and they are using version 1.2.0 :( I can't seem to ...
0
votes
2answers
709 views

Installing Wordpress via WP-CLI: not working with a bash script?

I am trying to make installations easier on my Mac using MAMP by using WP-CLI. I made a simple .sh file: wp core download wp core config --dbname=dbname --dbuser=root --dbpass=root wp db create wp ...
1
vote
1answer
979 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 ...
0
votes
1answer
91 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/...
2
votes
1answer
1k 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? ...
1
vote
3answers
844 views

Change old URLs after the domain change

I have setup wordpress on my server, and after some time I've changed the domain name of the installation. However, all of the old urls within the site point to the old domain. How can I change old ...
0
votes
0answers
65 views

I can not update fields with the tax_input tag using wp cli

i'm using this command for update in command line using wp-cli tool. wp post update 12349 --meta_input='{"opalestate_ppt_parking":"2"}' --tax_input='{array('opalestate_statuschecklist' => 'rent')}'...
0
votes
0answers
16 views

Unit test for wordpress plugin

I have followed wordpress office blog -->https://make.wordpress.org/cli/handbook/plugin-unit-tests/ to implement unit testing in plugin. I have been able to write a simple test on one of my method of ...
1
vote
2answers
70 views

XDG-OPEN is not recognized by WP CLI admin command

So i installed the wp admin package, but i can't seem to get her working, an error pops up telling me xdg-open doenst exist.. For install i used: wp package install git@github.com:wp-cli/admin-...
0
votes
0answers
86 views

Can run cron event manually with WP-CLI but not with any plugin, unsure if it's being scheduled

I have a cron event that I am able to manually run with wp cron event run --all When I go to my dashboard and go to WP-Crontrol OR Advanced Cron Manager, I can see my event listed and tell it to ...
1
vote
2answers
81 views

How to specify to wp-cli for the `wp config create` (`wp core config`) command that the DB user is an 'all hosts' user?

My wp config create command: wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password' Running it: $ wp core config --dbname=wordpress --dbuser=wordpress --...
1
vote
1answer
465 views

How to clear Transients on all sites in Multi Sites environment

I know we have the following command available in WP-CLI to remove transients # Delete all transients $ wp transient delete-all However, my question is does it remove transients on all sites over ...
2
votes
1answer
44 views

In a continuous integration environment how do you implement the database entries for plugins and themes

I'm setting up a wordpress continuous integration environment - git->composer->bitbucket-AWS codepipeline, etc. I have yet to figure out how I automate, for the development team, the setup of the ...
1
vote
1answer
92 views

Different output from WP-CLI in bash vs PHP exec()

I installed this package on WP-CLI. When I run wp login create in bash it works fine, but when I run exec("wp login create") in PHP script WP-CLI return this error: Error: 'login' is not a ...