Skip to main content
4 votes
Accepted

Shortest way to install WP-CLI

Downloading the Phar file is the recommended installation method for most users. As you showed, it's basically just one line. It can't really get shorter than that. And the steps make sense: download ...
swissspidy's user avatar
  • 3,844
4 votes
Accepted

How to disable XML-RPC from Linux command-line in a total way?

On nginx, to block access to the xmlrpc.php file, add this location block to the server block of your configuration file: location ~ ^/(xmlrpc\.php) { deny all; }
Nathan Johnson's user avatar
3 votes
Accepted

Bulk delete media by year

We tried with couple of plugins , but there isn't any with option to bulk delete images by month or year. If you have access to wp-cli you can try to delete attachments by year and month with: wp ...
birgire's user avatar
  • 67.4k
3 votes

How do I set and list page_template with wpcli?

This doesn't have the attribute I am looking for page_template Try using page_template in fields: wp post list --post_type=page,post --fields=ID,post_title,post_name,post_type,page_template
Prisoner 13's user avatar
3 votes

How to change a post attribute to homepage using WP CLI?

To set the site's static home page with WP-CLI, you should be able to do something like this: wp option update show_on_front "page" wp option update page_on_front {$page_id} ... where {$page_id} is ...
Pat J's user avatar
  • 11.9k
2 votes
Accepted

wp-cli for Creating page-template

wp-cli is not a development tool, it is a server admin tool, as such all the scaffold stuff there is.... for lack of better word, unneeded bloat. It is unlikely to reflect best practice, especially if ...
Mark Kaplun's user avatar
  • 23.4k
2 votes
Accepted

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="$...
lofidevops's user avatar
2 votes

Find Wordpress root directory in bash without WP-CLI

Simple bash script to find your WordPress root Ever need to run a script outside of WordPress and need to know the WordPress root directory? while [ ! -e wp-config.php ]; do if [ $pwd/ = / ]; ...
Slam's user avatar
  • 343
2 votes

wp-env mysqlcheck error:1130

Step 1: Find the name of your wp-env container First, you need to locate the name of the container created by wp-env. To do this, in the directory of your project containing .wp-env.json, you must run ...
Greys's user avatar
  • 46
2 votes

Carriage Return control character (^M) found in wp-config-sample.php

Unix and Unix-like operating systems (like Linux) use different line endings in their text files. The format of Windows and Unix text files differs slightly. In Windows, lines end with both the line ...
Pat J's user avatar
  • 11.9k
1 vote

Bulk delete media by year

Your images still exist in your Media Library because they are stored in the database, just like posts and pages. You can delete an image directly via FTP, but that doesn't magically delete its ...
DeltaG's user avatar
  • 899
1 vote
Accepted

WP Cli will not execute on Windows

Currently i have several process running in my CI/CD with wp-cli and all works fine in windows and unix. In my experience this is your best option in windows: #1 Add PHP to your Windows Path Variable #...
Vitor Almeida's user avatar
1 vote

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

Changing fonts and stripping tags can be done with a mySQL query. You'll just need to figure out the right regexes to search and replace. For everything else, it sounds like you would be better off ...
WebElaine's user avatar
  • 9,440
1 vote

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

WP CLI is probably the best for this: WordPress Version: wp core version --path="$SITEPATH" > wp-report.txt List Plugins: wp plugin list --path="$SITEPATH" >> wp-report.txt List Themes: ...
majick's user avatar
  • 5,091
1 vote

How can I use PurifyCSS to clean WordPress style.css?

Optimizing the CSS for WordPress is a time consuming job. You will have to consider all pages (404, archive, search, etc) as well as every possible element that you can think of, such as images, ...
Johansson's user avatar
  • 15.3k
1 vote

Error updating WP-CLI

First of all, locate your installation of WP-CLI. If you're using Composer you can list all globally installed packages on the command line like this: composer global show Then update the WP-CLI ...
Sven's user avatar
  • 3,644
1 vote

Generate WP-CLI @alias for each site on multisite

LOCAL For local aliases, it works best to define your path ahead of time in the config.yml. Then keep the variables pretty clean by only specifying the url to target the site. Sorting the output ...
jgraup's user avatar
  • 9,764
1 vote

Database Update Required - Update from command-line

Core updates are supported in the WP-CLI. wp core update - Update WordPress. # Update WordPress $ wp core update Updating to version 4.5.2 (en_US)... Downloading update from https://downloads....
jgraup's user avatar
  • 9,764
1 vote

How do I pass an array as an argument to a WP-CLI command?

A solution inspired by @Saulo Padilha . <- the only person on the whole internet taking this cr*p seriously 😂 Add this snipped to functions.php , set the user argument, and JSON input should work. ...
Davey's user avatar
  • 178
1 vote

How do I pass an array as an argument to a WP-CLI command?

It's 10 years old, but WP-CLI still doesn't handle the taxonomies while using wp post create. So let's say you have the command: wp post create --post_type=book --post_title="The Book" --...
Saulo Padilha's user avatar
1 vote

wp-cli displays php notices when display errors off

My solution to disable notices etc is to know if the wp-config.php is call via cli or not. So put this little code in wp-config.php $sapi_type = php_sapi_name(); if ( $sapi_type == 'cli' ) { ...
Mickael Bertainchant's user avatar
1 vote

How to use command 'wp post create' in wp-cli properly?

In case you have many post to create, you can create a dedicated folder with all your posts as text documents, using post_title as the txt file titles. In this very same folder, create a bash file ...
kartonnade's user avatar
1 vote

Get plugin download URL from slug

I think I am late but as per new guidelines I found this is best possible solution // Set the arguments. For brevity of code, I will set only a few fields. $args = array( 'slug' => '...
Suneel Kumar's user avatar
1 vote

Determining WordPress' Version from the Host's Command Line?

If you want to use that information for something in a script, you can do this: VERSION=$(grep "wp_version =" wp-includes/version.php | awk '{print $3}' | sed "s/'//g" | sed "s/;//g") That would ...
Juanjo Espí's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible