WP CLI: search and replace specific directory name of URL

Instead of using ” to wrap your expressions, use ‘. Further experimenting shows me that this is incorrect—both ” and ‘ should work, as long as they’re matched (ie, you don’t accidentally try something like wp search-replace “domain.com/wp-content/uploads/(\d)/(\d)/(\d*)/’ “domain.com/wp-content/uploads/\$1/\$2/” –precise –all-tables –skip-columns=guid –regex. (Note that the regex in that example starts with ” and ends … Read more

Update custom plugin with WP-CLI

You would implement this: https://make.wordpress.org/core/2021/06/29/introducing-update-uri-plugin-header-in-wordpress-5-8/ First you would add a Update URI: header to your plugin with a custom domain. Second, you would add a filter to your plugin, using the filter name update_plugins_{$hostname} where {$hostname} is the value you gave your Update URI: . E.g. Update URI: example.com would have the filter update_plugins_example.com. In … Read more

wp-cli only displays PHP version for all input options

Try running php wp-cli.phar EDIT It looks a little like php on your system isn’t setup to use php-cli (it’s using php-cgi instead): try running: php -v on my machine I get: PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with … Read more

Duplicated site isn’t recognized as a site

Error is from the last command wp search-replace “${domain}” “test” –allow-root. Your WordPress site is not yet installed and you want to execute command which require WordPress to be installed. Earlier in script you are dropping test database and creating new one, but you have to fill it with WordPress tables. Without this tables WordPress … Read more

How can I list all installed plugins/themes/versions from CLI/API?

Using WP CLI, you can record WordPress version using: wp core version –extra –path=”$SITEPATH” > wp-report.txt and append a list of plugins (with status and version): wp plugin list –path=”$SITEPATH” >> wp-report.txt and append a list of themes (with status and version) using: wp theme list –path=”$SITEPATH” >> wp-report.txt Further reading: https://developer.wordpress.org/cli/commands/core/version/ https://developer.wordpress.org/cli/commands/plugin/list/ https://developer.wordpress.org/cli/commands/theme/list/

Do all WordPress installations include WP CLI by default

WP-CLI is not part of the WordPress software itself. It’s something that gets installed on the server, but you don’t need to install any plugins or anything in WordPress for it to work. Whether or not you can use WP-CLI depends on whether your host has it installed, or let’s you install it, and whether … Read more

Migrating Multisite with WP-Cli and/or Search-Replace-DB

Accepting a little egg on my face. Dumb-dumb error. The above migration was 100% successful despite the error messages from WP-Cli and Search Replace DB. The reason that my theme appeared broken and other weird issues.. I forgot to re-enable my plugins folder that had been re-named “plugins_temp_disabled”, while troubleshooting a different problem. Good night … Read more

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

There is no wp-cli command to delete a post by title, but you could easily roll your own. Adding something like this in you current themes function.php file would work: if (defined(‘WP_CLI’) && WP_CLI) { class CYCLONECODE_WP_CLI_COMMANDS extends WP_CLI_Command { /** * Delete post by title. * * ## OPTIONS * * <title> * : … Read more

MySQL 5.6 Causes Errors with WP CLI

Resolved the issue. The problem was that the default PHP version changed with the new version of MAMP, and I had set the path in .bash_profile to the explicit version of the previous MAMP install. Once I edited the .bash_profile to dynamically find the version of PHP in use, everything works perfectly.