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.
386
questions
0
votes
1
answer
8
views
Which WP-CLI commands can be safely run with --allow-root flag?
Over the past several years, WP-CLI has become pretty popular, but there's still a lot of warnings about the --allow-root flag for security reasons, and instead developers are urged to use non-root ...
0
votes
0
answers
10
views
Is there a technical difference between invoking `wp-cron.php` and using `wp cron event run`?
For years I've been running cron by setting DISABLE_WP_CRON to true in wp-config.php and then setting up a cron on my server that runs like this:
* * * * * cd /path/to/site/public_html && /usr/...
0
votes
0
answers
22
views
Is there a WP CLI hook for handling ctrl+c
I know there are hooks for writing custom commands as found here: https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-add-hook/
In my case, I want to handle cleaning up on exit (...
1
vote
0
answers
17
views
How to revert the media structure from /uploads/year/month to the /uploads directory in wordpress?
I tried to use wp-cli using regex like this:
wp search-replace 'uploads/[0-9]+/[0-9]+/' 'uploads/' --all-tables --regex
but in this case there is a problem with possibly repeated file names and ...
0
votes
1
answer
35
views
Changing boolean value with "wp option patch"
I am trying to change a boolean value (in a serialized object) via wp option patch. But it doesn't work. If I use true (without quotes), it changes to string, if I use 1, it changes to int. Is there a ...
2
votes
2
answers
275
views
What are the proper permissions for production use of wp cli
I am running several instances of WP on GCP VMs and a test VM setup with Ubuntu 22.04 / PHP8.1 and followed the instructions at https://make.wordpress.org/cli/handbook/ to install wp cli.
The wp info ...
0
votes
1
answer
56
views
Cannot Flush Permalinks with WP-CLI
I am using wp-cli to create a WordPress website. I am running LAMP server. I am able to change the permalinks from ugly to pretty with the following commands:
wp rewrite structure '/%postname%'
wp ...
0
votes
1
answer
10
views
wpcli search-replace fails; reports that mysqli needs to be installed
I'm trying to run 'wp --search-replace' within a vhost webroot on an apache host.
The operation returns:
Please check that the `mysqli` PHP extension is installed and enabled.
If you are unsure what ...
0
votes
0
answers
46
views
Skip un-set meta fields ("Invalid field: fieldname") when using `wp post list` and displaying custom fields
We have custom fields called country
and coordinator.
This works:
$ wp post list \
--post__in=81153 \
--post_type=boardmember \
--fields=ID,post_title,post_name,post_date,post_status,country,...
0
votes
0
answers
134
views
Trying to run only certain action-scheduler tasks from WP-CLI
I'm writing a plugin that performs several actions, one of which is a complex routine that parses and imports a large Excel spreadsheet (don't ask). I want this routine to run as a background task, ...
0
votes
0
answers
44
views
Uncaught Error: Class ‘WP_Upgrader_Skin’ not found
WP-CLI 2.9.0 run with –debug
….
Debug (bootstrap): argv: /bin/wp core check-update –debug –path=/home/web/public_html (0.752s)
Debug (bootstrap): ABSPATH defined: /home/web/public_html/ (0.752s)
Debug ...
2
votes
0
answers
34
views
@wordpress/env cli doesn't seem to properly update permalink structure until visiting the WP Admin Permalink settings page
I'm using https://www.npmjs.com/package/@wordpress/env to set up a local docker-based WordPress development environment, which has been working great so far. I'm trying to build a script using ...
0
votes
0
answers
194
views
Unknown phantom user "wordpress" created with admin privileges
We've been seeing a user created out of nowhere named "wordpress" every so often, with most of our wordpress sites on a couple Ubuntu 20 servers. I run a quick audit across our server using ...
0
votes
0
answers
100
views
Could not reset Wordpress user password using WP CLI
I have a wordpress site (6.2.2). I forget my admin password. The site is not setup with SMTP yet, so the forget password link won't work.
I tried several ways, but none of them works.
1. WP CLI - No ...
0
votes
0
answers
132
views
WP-CLI delete customers in bulk
I have a staging site and need to give an access to developers.
So, I have to delete all customers just in case.
I have below command. But I feel there should be better command.
Can you advise?
wp ...
0
votes
0
answers
57
views
Does wp i18n CLI has a prototype of "update-json" file?
I correctly internationalized a javascript file from wp theme folder.
Now I would like to know if Wordpress team plans to propose a CLI to update json without losing existing translation.
It seems ...
0
votes
0
answers
269
views
WP-CLI PHP Deprecated Warning
Under WordPress 6.3, PHP 8.2, MySQL 8.0.34, WP-CLI 2.8.1, for wp command like this:
wp post list --post__in=mypostid
I have this warning:
Deprecated: Creation of dynamic property Post_Command::$...
2
votes
1
answer
65
views
WP CLI switching post status from publish to future not working?
I want to use wp cli to change post status from published to future, however it appears that once a post is published, it can no longer be switched to future. When I try to do this the post remains ...
1
vote
1
answer
198
views
How can I use xdebug with wp-cli
I'd like to use xdebug and vscode to debug a script I'm running via wp eval-file.
My launch.json is pretty basic.
{
"name": "Listen for Xdebug",
"...
0
votes
1
answer
575
views
Warning: Constant WP_DEBUG already defined
PHP 8.1.17
WP-CLI 2.7.1
WP set up as multisite network
Adding the following line to wp-config.php (line 107)…
define('WP_DEBUG', true);
…causes wp-cli to report the following…
$ wp plugin list
...
0
votes
1
answer
261
views
Run a WP-CLI command from within PHP without using shell_exec()
Is there another way for me to run a WP-CLI command from within a PHP script other than using the shell_exec() function.
-1
votes
1
answer
218
views
Should I run wp cron event run via crontab or as a daemon?
In my server I've run:
sudo -u www-data wp cron event run --path=/var/www/blog.example.com --all
But I do not know should I run wordpress cron using crontab or make it into a service using systemd ...
0
votes
0
answers
53
views
Trying to remove all references from old domain in wordpress site after migration to new domain
I have moved a website from old domain to new domain and have used the following WP CLI command
$ wp search-replace --skip-columns=guid "olddomainname.com" "newdomainname.com"
...
0
votes
1
answer
667
views
'wp' is not recognized as an internal or external command, operable program or batch file
I can't get WP-CLI to run on Windows.
Downloaded https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar to c:\wp-cli\wp-cli.phar,
Added c:\wp-cli\ to the System & User Path ...
0
votes
1
answer
299
views
What is the correct way to implement wp-cron server-side in Kubernetes?
I'm not sure if this is the correct place to ask the question, but since this is specific to deploying WordPress, I thought I'd ask here first. What is the correct way to implement wp-cron server-side ...
0
votes
0
answers
60
views
Transitioning a big blog to WEBP images
I have a Wordpress site with a LOT of posts that still get significant amount of traffic (10,000's of posts).
The site is image heavy and uses <img> tags for inline Jpegs as featured and inline ...
1
vote
1
answer
435
views
Batch Replace URLs in Wordpress Database
I will be using this command with WP-CLI to batch change about 1,000 URLs.
while IFS=, read orig new; do wp --dry-run --skip-themes --skip-plugins search-replace "$orig" "$new" ...
1
vote
1
answer
164
views
wp media regenerate says "no regeneration needed" whe that's no the case
I'm trying to generate thumbnails for a PDF attachment. Right now in the uploads/ folder there is only the PDF file, no image thumbnails related to it.
But when I run the regeneration with :
wp media ...
0
votes
1
answer
36
views
Disappearing plugins
I've had a problem with disappearing plugins lately. Several of my plugins are installed and are working, but you can't see them in the admin plugin interface, only WP-CLI. The plugins are "...
0
votes
2
answers
109
views
Post Count for Multisite?
Is there a way to get post count for all active sites on a multisite, using WP-CLI? Conceptually, I'm looking for a combination of wp post list --format=count and wp site list --format=count but I don'...
0
votes
0
answers
237
views
is it possible to use wp cli to export custom post types
i have been trying to use WP CLI to export custom post type 'product' from custom taxonomy 'product_brand'. however, my command is exporting a random list of products, from other brands. it also is ...
0
votes
1
answer
160
views
wp cli media commands not working
I am trying to bulk update media file captions through WP CLI so i can attribute image creators.
My command is as follows:
wp media list --date="2022-02-24" --format=ids | xargs -n 1 wp ...
1
vote
1
answer
29
views
Why doesn't "wp db cli" enable tab completion?
I would like to use tab completion when using the MySQL REPL accessed by running wp db cli. However it doesn't seem to work, even though my ~/.my.cnf file contains this content:
[mysql]
auto-rehash
...
1
vote
0
answers
43
views
Why not attaching images after impoting using wp cli
I want to move posts from one site to another, because of the big amount of posts I am trying with wp-cli import. The destination site also has huge amounts of posts, now when I am importing XML files....
2
votes
0
answers
297
views
Using wp-cli on remote with quoted commands
I have my wp-cli.yml configured with a working ssh connection.
If I wp db query "CHECK TABLE $(wp db tables | paste -s -d, -);" and run locally it works just fine.
On the other hand, if I wp ...
-1
votes
1
answer
310
views
Weird WP -Cli Error Connection Refused
I have a rather of wp-cli problem.
I am using wp-cli to import a db from my test server into my staging server and even though the import is successfully and everything seems to be working correctly ...
0
votes
1
answer
252
views
Can WP-CLI modify database connection details in existing wp-config file?
I am aware of WP-CLI's many database interaction functions via "wp db" and its functions for generating wp-config files via "wp config" - However I cannot find a way of using WP-...
1
vote
1
answer
218
views
Does DISABLE_WP_CRON prevent plugins from registering new cron tasks?
If I set DISABLE_WP_CRON to true in my wp-config.php file, then will it block plugins from registering new cron events (eg with calls to wp_schedule_event())
define( 'DISABLE_WP_CRON', true );
I've ...
2
votes
1
answer
185
views
How to install WordPress with Composer?
I want to install WordPress and WP CLI both with Composer.
This is how I install Drupal and Drush (Drupal's CLI tool) with Composer:
cd WEB_APPLICATION_ROOT
composer create-project drupal/recommended-...
1
vote
0
answers
95
views
wp-cli output 'column display format' / wrapping
First of, I'm not sure what the correct technical name is for this.
The problem is the display width for the first column (or maybe total table width) on commands like
wp plugin list
and it outputs ...
0
votes
0
answers
72
views
WP-CLi Uable to Install / Update Plugins
From the command WP-Cli is unable to install or update plugins, throwing the following error:
The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir ...
0
votes
1
answer
107
views
wp-cli incorrectly believes a plugin is currently installed
I ran wp plugin deactivate woocommerce --uninstall and it did so successfully. I verified with #ls wp-content/plugins the woocommerce folder no longer exists.
Problem:
when I run wp plugin install ...
0
votes
0
answers
60
views
WordPress CLI isn't working while use WordPress development repository
I cloned the repo from https://github.com/WordPress/wordpress-develop.git
After that followed the README file from the downloaded code and installed node dependencies and execute the below commands in ...
1
vote
0
answers
99
views
Remote Export DB w. WP-cli.phar Over SSH
I am trying to export a remote wp db using the following:
source_gzip_db=git-dumps/export.sql.gz
source_path_to_wordpress=/home/username/public_html
source_ssh_host="123.456.789.12"
...
0
votes
1
answer
444
views
When might you need to specify the "url" argument/option in WP-CLI?
I have read several blog posts and discussions about the url option in WP-CLI and have seen many different opinions and interpretations, so I assume I'm not alone with this question...
The official ...
0
votes
1
answer
42
views
What is the purpose of the "user" global parameter in wp-cli.yml config?
According to WP-CLI documentation, you can specify "user" using inline arguments, or in the global configuration.
I understand there might be a task you want to run against a specific ...
0
votes
0
answers
118
views
WP-CLI Add category as menu item main-menu
I've found this documentation about adding terms using WP CLI: https://developer.wordpress.org/cli/commands/menu/item/add-term/ and tried to find out how I can add an existing category to the main-...
0
votes
1
answer
155
views
wp_clear_object_cache() is deprecated. What should I use instead?
Today I noticed that \WP_CLI\Utils\wp_clear_object_cache() has been marked as deprecated in WP-CLI 1.5.0. The release notes don't mention anything about it. What should be used, instead? Do I still ...
2
votes
1
answer
195
views
Setting boolean and array values using wp theme mod set
I need to set a couple of Theme Mods to boolean and array values using WP CLI but can't find any way to do achieve it.
I have already tried the following for booleans, but they appear to be treated as ...
1
vote
2
answers
774
views
How to find what pages/posts contain a particular reusable block?
How can I find out what pages and post on a site contain a particular reusable block?
Typically, to find content on a site, I issue wp db search *itemlookingfor* (like the post ID, part of a file name,...