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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
21 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 ...
0 votes
1 answer
39 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
20 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
17 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
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.
4 votes
2 answers
3k views

"Could not open input file" error even when WP-CLI is in the path

I'm developing Wordpress locally with XAMPP, and currently trying to install the WP-CLI tools as described here using Cygwin. I renamed wp-cli.phar to wp, made it executable and moved it to the ...
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:/...
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!
0 votes
0 answers
23 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-...
1 vote
1 answer
100 views

When WP_CLI runs Wordpress from the command line, are hooks called?

Yesterday, I found out that a website I worked on as a writer (I have no admin access) had been injecting malicious Javascript code in all its pages, as described in this article by Luke Leal. ...
0 votes
1 answer
645 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 ...
2 votes
3 answers
792 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
2 answers
611 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
1 answer
39 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 ...
1 vote
2 answers
711 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 ...
0 votes
0 answers
55 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 ...
2 votes
1 answer
32 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
1 answer
30 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,...
4 votes
0 answers
776 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) ...
7 votes
3 answers
5k 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
2 answers
454 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. ...
1 vote
1 answer
387 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 ...
0 votes
2 answers
174 views

Update custom plugin with WP-CLI

I made a custom plugin for inserting staging / production versions of a Google Tag Manager container based on the server's IP address. How do I make it compatible with WP-CLI so it will update when I ...
0 votes
2 answers
859 views

Can I use wp-cli to create posts with a custom post types?

I regularly need to create a batch of posts of a custom post type, with names and meta values that follow a regular pattern. This seems like a perfect canditate for using wp-cli, but so far it hasn't ...
1 vote
1 answer
705 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
0 answers
66 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 ...
0 votes
1 answer
134 views

Using WP-CLI, how do I delete a post by title or slug, not ID?

The docs show how to delete by ID. How do I delete by slug/title?
0 votes
0 answers
40 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 ...
9 votes
4 answers
10k 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 ...
0 votes
0 answers
48 views

DB option update with wp-cli

I am creating an automation script where I use wp-cli to do plugin/theme installations, configure settings and other. This script is installing the Enfold Parent and Child theme from Kriesi and after ...
0 votes
1 answer
776 views

Trying to install Wordpress on WSL Windows 10, and running into issues with wp-cli and "wp db create"

Okay so I'm following this tutorial: https://hellojason.net/blog/how-to-setup-wordpress-locally-on-windows-subsystem-for-linux/ I had to do a bunch of monkey around to get MySQL to work because for ...
1 vote
0 answers
35 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 --...
0 votes
1 answer
142 views

WP CLI: search and replace specific directory name of URL

I am trying to use wp cli (with regex) to search and replace. I want to change: domain.com/wp-content/uploads/2020/04/asdnbahsdjhgzw/picture.jpg to domain.com/wp-content/uploads/2020/04/picture.jpg So ...
0 votes
1 answer
88 views

wp-cli error: "Term is missing a parent"

When I try to export posts via the command line, I get an immediate error that the term is missing a parent: $ wp export Starting export process... Error: Term is missing a parent: name-of-tag (123) ...
1 vote
1 answer
152 views

Get last published post in Wordpress using wp-cli

I'm using below wp-cli command to get latest post ID: wp post list --order='DESC' --orderby='ID' --field='ID' | head -1 This, however is inefficient as all posts are retrieved from DB and then head ...
2 votes
1 answer
502 views

Configuring WP-CLI on Windows 10

I've installed php5-cli using bash, but Wordpress is using XAMPP's PHP 7 install. I've added /mnt/c/xampp/php to the PATH, and I've explicitly used export WP_CLI_PHP='/mnt/c/xampp/php' in .bashrc. ...
1 vote
1 answer
222 views

WP Cli will not execute on Windows

I have tried to install Wordpress CLI on my windows machine running windows 10. But for some reason everytime i try to run the wp Command it says 'sh' is not recognized as an internal or external ...
0 votes
0 answers
147 views

wp-cli + valet: "Error establishing a database connection"

I'm running Laravel Valet to get a simple WP local development environment. Strangely at some point wp-cli stops being able to do much and gives me a "Error establishing a database connection&...
0 votes
0 answers
139 views

wp option get blogname --url=my-sub-site.com returning main site option

I have a multisite setup with some 14 woocommerce sites. site_id | domain 1 | local.mainsite.com 2 | local.subsite-2.com 3 | local.subsite-3.com 4 | local.subsite-4.com I want ...
0 votes
1 answer
2k views

Can't Connect to MySQL Database using WP CLI and MAMP on a macOS Catalina, using Oh My Zsh

I'm running macOS Catalina and am trying to use WP CLI with MAMP, with iTerm2 and Oh My Zsh as my command line. However in my localhost directory when I enter wp in the command line, and then press q ...
0 votes
1 answer
207 views

Working with CLI and missing my namespace classes inside

I'm very new to WordPress development. I hit this error when i developering my own class and namespace to do the life easier to reuse my code on cross of platforms/frameworks. I have added my CLI ...
4 votes
2 answers
194 views

Prompt user for input in WP CLI

I am missing some feature to prompt the user for input. In Laravel we have $this->ask('What is your age') (https://laravel.com/docs/8.x/artisan#prompting-for-input) I haven't been able to find any ...
0 votes
0 answers
37 views

WP CLI custom plugin commands not available on production server

I have WP All Import on one website and I've realized that WP CLI doesn't load the plugin custom commands. It's not related to WP All Import though, because there should be even other plugins commands ...
2 votes
1 answer
330 views

Get WP CLI to hide debug warnings and notices in JSON output, same setting as website

Summary: WP CLI can be used to get a JSON output of all the plugins installed on a site, but the output gets corrupted due to warnings although log levels are set to low. Problem Unfortunately, I have ...
0 votes
1 answer
38 views

adding wp-cli commands to plugin: how to document to users?

I'm adding wp-cli support to a plugin of mine. Is there an accepted way of letting my users know they can use wp-cli with my plugin? I can put stuff in my readme.tx of course, and I can put an ...
1 vote
0 answers
37 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 ...
0 votes
1 answer
755 views

Is it possible to use WP-CLI in a plugin (or theme)?

Is it possible to use WP-CLI in a plugin (or theme)? Such as $ret = \WP_CLI::execute('plugin list'); I want to use some subcommands from other plugins.
2 votes
0 answers
100 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 ...
2 votes
1 answer
75 views

Does thumbnail regeneration edit the database?

I'm using the WP CLI command wp media regenerate to resize all of the images via the /wp-content/uploads directory. Are the new image dimensions registered in the database in any way or does the ...
4 votes
2 answers
1k views

WP-CLI - Return posts with matching meta key

I am using the WP-CLI to manage my sites. I can run the following command wp post list --fields=ID,mycustomfield ID | mycustomfield ----------------------- 1 | active 2 | active 3 ...

1
2 3 4 5
8