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.

112 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
1 answer
630 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
1 answer
516 views

How can I list only sites that use a particular theme or plugin?

I need to search through dozens of WordPress multisite (network enabled) installs for sites that use a particular plugin. How can I list only sites that use a particular theme or plugin, preferably ...
iroast's user avatar
  • 41
4 votes
0 answers
972 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) ...
user658182's user avatar
3 votes
0 answers
720 views

Setting Up PHPUnit tests for WP development on Windows

I've been following the instructions in this article to try to set up some testing. I got as far as this instruction bash bin/install-wp-tests.sh wordpress_test root 'mypass' localhost latest before ...
Robin Andrews's user avatar
2 votes
0 answers
194 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 ...
Tom Ransom's user avatar
2 votes
1 answer
81 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-...
yoine's user avatar
  • 21
2 votes
0 answers
117 views

Regenerate thumbnails unexpected resolution (96 x 96)

I'm using WP CLI wp media regenerate to resize my thumbnails. I've noticed something a bit weird. The original image I upload is a JPEG with a resolution (DPI) of 72. The images that are generated ...
Sam's user avatar
  • 2,106
2 votes
0 answers
374 views

How to get all posts related to a term with WP-CLI?

I want to get all french brands. When I try with post type brand, it works (for example it returns 1000 results). wp post list --post_type=brand If I add a parameter: taxonomy term (--<taxonomy>...
Dacobah's user avatar
  • 121
2 votes
0 answers
136 views

WP WPQuery, not running properly in WP CLI

I'm running a simple query just to find simple WooCommerce products, here is the query which works fine in the header of the site: $args = array( 'post_type' => 'product', 'posts_per_page' =...
WebDevB's user avatar
  • 121
2 votes
0 answers
377 views

WP CLI: there has been critical error

I am using Wordpress 5.3 minimal installation and currently have not installed any other plugins. I have installed WP CLI and below is the output of wp-info: OS: Linux 5.0.0-1025-gcp #26~18.04.1-...
Ravi Maniyar's user avatar
2 votes
0 answers
842 views

ACF image field to WordPress featured image

I am working with a CPT that is using ACF fields to manage content and the hero image. With the new Archive page template, I wish to have featured images alongside the content. Earlier we did not ...
patilswapnilv's user avatar
2 votes
0 answers
136 views

How can I add an RSS widget using WP-CLI?

I can add an rss widget with this command: wp widget add rss my-sidebar --title=News --items=5 But when I add a URL parameter, like this: wp widget add rss my-sidebar --title=News --items=5 --url=...
Jonathan's user avatar
  • 429
1 vote
1 answer
96 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 ...
mike23's user avatar
  • 5,931
1 vote
0 answers
30 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....
Mi2's user avatar
  • 11
1 vote
0 answers
70 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 ...
piet's user avatar
  • 111
1 vote
0 answers
63 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" ...
mjones's user avatar
  • 153
1 vote
0 answers
106 views

How can i preserve wordpress database encoding after using wp-cli search-replace with --export flag?

I need to migrate a wordpress database to another server but first i need to change all old url's, stored inside any table, to new ones. To do that, i'm using wp-cli search-replace function with --...
Max's user avatar
  • 121
1 vote
1 answer
2k views

WP CLI not finding plugin commands

On a Ubuntu 20.04 Linode I have a Wordpress installation. I deploy the website using https://github.com/Mixd/wp-deploy, a Capistrano deployment tool. When the website is deployed the folder structure ...
Roberto Cinetto's user avatar
1 vote
0 answers
56 views

Getting page output HTML without request (for CriticalCSS, PurgeCSS)

I work a lot with legacy website with css files which were shared across many pages which resulted in really bloated stylesheets shipping to browser. I want to do some performance tricks to avoid this ...
jamkaka's user avatar
  • 11
1 vote
0 answers
416 views

wp-cli command throws error : "SSL routines:tls_process_server_certificate:certificate verify failed" while querying https website

I use wp-cli with wp restful plugin installed. Running wp cli command wp rest user list --http=https://[url] throws below error: Error: Failed to get url '[url]': stream_socket_client(): SSL operation ...
rok's user avatar
  • 224
1 vote
0 answers
965 views

wp search-replace on database returns PHP fatal error: Array and string offset access syntax with curly braces is no longer supported

So I need to setup a client website locally for improvements. I'm trying to search and replace any instances of the live site's name/url and replace it with a development one. When I run the command: ...
Neil's user avatar
  • 11
1 vote
0 answers
653 views

How can I search and replace by post type?

I am trying to use WP-CLI to do a search and replace on about 10,000 posts that were imported from another CMS and it has a great deal of old inline styles and spans and such. I would like to be able ...
pathfinder's user avatar
1 vote
0 answers
519 views

Only the WP CLI command, wp --info, runs under my cPanel account

Please review the following commands I have issued remotely to the Bash Shell on my dedicated cPanel/WHM server: [root@host ~]# wp cli update Success: WP-CLI is at the latest version. Then I ...
Don's user avatar
  • 11
1 vote
0 answers
584 views

How to use WP-CLI / WC-CLI to bulk import 1000s of products (variable and simple)?

I am a junior developer and I have been asked to work on a wordpress site that has previously been using All Import plugin to upload products. The problem is, this is not functioning properly, and is ...
challenge2022's user avatar
1 vote
0 answers
142 views

Rebuild thumbnails via WP Cli - how?

I can use wp media regenerate to regenerate thumbnails. But I need to rebuild first, before I can regenerate. In the GUI of WordPress I have two buttons (if I have AJAX Regenerate Thumbnails plugin): ...
FooBar's user avatar
  • 424
1 vote
2 answers
686 views

Error establishing a database connection when running phpunit

I'm following https://make.wordpress.org/cli/handbook/plugin-unit-tests/ to run unit tests for plugins. I create a new plugin. $ wp scaffold plugin hello-plugin-1 Success: Created plugin files. ...
Haibin Liu's user avatar
1 vote
0 answers
789 views

How to delete 1000s of duplicated images in Wordpress?

We kinda have a wired problem that took me weeks of searching and testing, the problem is that while working on one of my client's Wordpress website I noticed that there are around 75k images in ...
Ali Rashidy's user avatar
1 vote
0 answers
37 views

Update a post based on results from GET request to another server

I need to use GET requests to retrieve the current status of a device and then update the body of a specific Wordpress post with the text data sent by the external device (for reference, it will use ...
Xhiko's user avatar
  • 11
1 vote
0 answers
230 views

WP-CLI search-replace posts content for certain URLs

Using WP-CLI I am wanting to search and replace posts content but only for certain URLs. This is what I have so far: $ wp search-replace 'Contact us today' 'Contact us today by filling in the form ...
ianhman's user avatar
  • 13
1 vote
0 answers
200 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 ...
Brethlosze's user avatar
1 vote
0 answers
164 views

WP-CLI cron on multisite using WP-Toolkit "succeded", but callback not executed

I'm trying to trigger WordPress crons within a multisite using Plesks WordPress toolkit. Generally it is working, but the callback doesn't seemed to be executed. The command to execute crons: /...
Adrian's user avatar
  • 271
1 vote
2 answers
1k 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!
Brooke's user avatar
  • 23
1 vote
0 answers
441 views

wp-cli search is returning 'search' is not a registered subcommand of 'db'

I'm trying to search for a string like this: wp db search some-string and get: Error: 'search' is not a registered subcommand of 'db'. See 'wp help db'. wp help db lists 11 subcommands and search is ...
user2718942's user avatar
1 vote
0 answers
241 views

Can I check which users ran which updates?

We have a site that was previously updated to 4.8.0. Two of us who normally perform updates did not have the right permissions to run the 4.8.1 update. Using wp-cli wp core update Error: Could not ...
nic's user avatar
  • 63
1 vote
0 answers
86 views

cURL to install theme

I can't figure for the head of mine how to write a cURL that would install a theme for me once I got a session. Tried binding these headers, but with no success: _wpnonce _wp_http_refferer _themezip ...
Dan Von's user avatar
  • 11
1 vote
1 answer
36 views

Resetting internal WordPress state during its cycle

Is there any api or system to reset internal cycle? I need this, cause when I use wp-cli in the shell I need to call for instance get_header more times in one session. The fast is when I call this ...
Salvio's user avatar
  • 85
1 vote
0 answers
101 views

wp-cli fails on installing to subdomain

it's likely I missed something, but I just tried to use wp-cli to install Wordpress on a subdomain. After succesfully downloading, creating wp-config and calling the install procedure with: wp core ...
Daniel Bachmann's user avatar
1 vote
1 answer
256 views

Error: reassigning content to a different user is not supported on multisite

Objective:There's a need to remove a user from the multisite. Before doing so, user's content needs to be "transferred to another user" in a subdomain setting/specific site that's not the parent. ...
yaris's user avatar
  • 11
1 vote
0 answers
244 views

How do I add HTML code to a widget with wp-cli?

I want to add a YouTube video to a widget via wp-cli. The YouTube video is basically an iframe. When I execute the following command: wp-cli widget update text-1 --text='<iframe src="http://...
Julian Suck's user avatar
1 vote
0 answers
52 views

For a specific theme, how do I build a list of all the possible theme modification names?

I'd like to use WP-CLI to modify a theme with wp theme mod. But, I do not know what all mods and their associated keys I can set with these commands. I've found that if I change a specific theme ...
landon's user avatar
  • 111
1 vote
1 answer
289 views

WP CLI Core install - blank database

A very strange thing has started happenning with my local WP installs... I am using latest version of MAMP Pro, and running: wp core install --url="http://example.local" --title="example" --...
Pete Norris's user avatar
1 vote
1 answer
560 views

WP-CLI can not find Url

When try use this command: php wp-cli.phar core install --url="http://example.com" the command fails. WordPress was installed, but WP CLI complains about an invalid siteurl and home because I have ...
unknown's user avatar
  • 11
1 vote
0 answers
454 views

Wildcard for wp-cli search-replace

I'm trying to perform this search replace: wp search-replace 'http://stage.contraindicaciones.net/app/uploads/2015/{08,09}/' 'http://stage.contraindicaciones.net/app/uploads/2016/03/' But curly ...
aitor's user avatar
  • 585
1 vote
0 answers
401 views

Update BackupBuddy with WP-CLI

I've written a script that basically loops through all of the WP sites on our server and updates everything: core, plugins, themes. It does, however run into one issue: It will not update BackupBuddy....
Seth Alling's user avatar
1 vote
1 answer
682 views

WP CLI not outputting anything

I am trying to use wp cli command line tool, but like many others it doesn't work for me. The site itself is loading with no issues. getting info does work: $ wp cli info OS: Linux 5.4.0-54-...
justadev's user avatar
  • 111
0 votes
0 answers
12 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 ...
Burak's user avatar
  • 1
0 votes
0 answers
16 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 ...
imagIne's user avatar
  • 45
0 votes
0 answers
79 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::$...
Brethlosze's user avatar
0 votes
1 answer
88 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.
TKEz's user avatar
  • 111
0 votes
0 answers
20 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" ...
Kiwiheretic's user avatar