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.

108 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
493 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 ...
user avatar
  • 9,469
4 votes
1 answer
206 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 ...
user avatar
  • 41
4 votes
0 answers
774 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) ...
user avatar
3 votes
0 answers
673 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 ...
user avatar
2 votes
0 answers
99 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 ...
user avatar
  • 1,923
2 votes
0 answers
186 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>...
user avatar
  • 121
2 votes
0 answers
109 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' =...
user avatar
  • 121
2 votes
0 answers
325 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-...
user avatar
2 votes
0 answers
812 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 ...
user avatar
2 votes
0 answers
119 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=...
user avatar
  • 401
1 vote
0 answers
33 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 --...
user avatar
  • 121
1 vote
1 answer
378 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 ...
user avatar
1 vote
0 answers
36 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 ...
user avatar
  • 11
1 vote
0 answers
243 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 ...
user avatar
  • 225
1 vote
0 answers
649 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: ...
user avatar
  • 11
1 vote
0 answers
257 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 ...
user avatar
1 vote
1 answer
278 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-...
user avatar
  • 111
1 vote
0 answers
360 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 ...
user avatar
  • 11
1 vote
0 answers
437 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 ...
user avatar
1 vote
0 answers
77 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): ...
user avatar
  • 396
1 vote
2 answers
449 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. ...
user avatar
1 vote
0 answers
569 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 ...
user avatar
1 vote
0 answers
36 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 ...
user avatar
  • 11
1 vote
0 answers
145 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 ...
user avatar
  • 13
1 vote
1 answer
54 views

How to retrieve text only from a post using WP CLI?

I have the post ids and urls. I need to extract the post content make some modifications and update again. I have more than 2,000 posts hence I would like to do it using WP CLI and not manually. Can I ...
user avatar
  • 153
1 vote
3 answers
787 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 ...
user avatar
  • 111
1 vote
0 answers
156 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 ...
user avatar
1 vote
0 answers
95 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: /...
user avatar
  • 239
1 vote
0 answers
76 views

How to change user admin_color with WP CLI?

I like to know how I can change a users admin color theme with WP CLI.
user avatar
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!
user avatar
  • 23
1 vote
0 answers
374 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 ...
user avatar
1 vote
0 answers
152 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 ...
user avatar
  • 53
1 vote
0 answers
80 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 ...
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 ...
user avatar
  • 85
1 vote
0 answers
83 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 ...
user avatar
1 vote
1 answer
162 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. ...
user avatar
  • 11
1 vote
0 answers
183 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://...
user avatar
1 vote
0 answers
47 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 ...
user avatar
  • 111
1 vote
1 answer
264 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" --...
user avatar
1 vote
1 answer
438 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 ...
user avatar
  • 11
1 vote
0 answers
393 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 ...
user avatar
  • 485
1 vote
0 answers
393 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....
user avatar
0 votes
0 answers
20 views

POT file generated using WP-CLI does not retrieve strings from translation functions with FQN (Qualifier)

I am generating .pot files by using the WP-CLI command above: wp i18n make-pot ... It works well, but it does not retrieve strings from translation functions with FQN (Qualifier). Example: \__( 'This ...
user avatar
0 votes
0 answers
16 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-...
user avatar
0 votes
0 answers
20 views

WP-CLI: Does "wp post create" will create post normally and will ping to Ping Service?

Is post created using WP-CLI is just a normal post that will ping to Ping Service? I scared if Ping Service not triggered on my new post using WP-CLI.
user avatar
  • 191
0 votes
0 answers
24 views

WP-Cli Error When Mapping Multisite Subdomain

I have a multisite located at example.com which has a subsite located at subsite.example.com. I followed the official Wordpress.org documentation to map subsite.example.com to otherexample.com https:/...
user avatar
  • 143
0 votes
0 answers
20 views

Bulk update published posts date randomly using wp-cli?

I see an option ([--post_date=<post_date>]) in wp-cli, but how can we use wp-cli to update all my published posts date randomly? For example, I want all posts date changed randomly between 01-01-...
user avatar
  • 1
0 votes
0 answers
50 views

Wordpress Import (CLI) returns Error Establishing a database connection

I am trying to use the wp import cli in the terminal to import a large wxr file (200MB) from the old test server to new test server. I can login to wp-admin using the admin account and mysql cli mysql ...
user avatar
0 votes
0 answers
65 views

Trying to install/configure wp-cli for WordPress

I'm trying to install/configure wp-cli for my WordPress website but I keep getting an error everytime I try and run a command. I have a VPS server with Bluehost and I followed a simple installation ...
user avatar
0 votes
0 answers
36 views

Using the WP CLI to output the HTML results of calling a post?

I’ve inherited a strange site, where the posts in the backend are built not in the WP editor, but in a series of ACF repeater blocks. I need to format / migrate these posts in a way that they can be ...
user avatar