Export backup copy of WordPress database into safe folder two steps below current folder

wp db export ../before-final-fixes.sql --all-tablespaces --allow-root

Import images into WordPress Media Library

wp media import ~/Pictures/**/*.jpg

Backup WordPress database

wp db export ../before-final-fixes2.sql --all-tablespaces --allow-root

Import or restore WordPress database

wp db import ../before-final-fixes2.sql --all-tablespaces --allow-root

Profile is a Package that helps with speeding up WordPress

wp package install wp-cli/profile-command

Package that allows you to remove or revise article revisions from the command line … and limit revision too.

wp package install trepmal/wp-revisions-cli

Very useful commands for when you run out of memory installing a package. This temporarily increases memoory and gets the install done .. even on godaddy!

php -d memory_limit=512M &amp;amp;quot;$(which wp)&amp;amp;quot;package install git@github.com:wp-cli/profile-command.git

Another example of the momeory hack

php -d memory_limit=512M &amp;amp;quot;$(which wp)&amp;amp;quot; package installtrepmal/wp-revisions-cli

Userful command for anlalyzing WordPress Performance

wp package install git@github.com:wp-cli/doctor-command.git

description

wp package install trepmal/wp-revisions-cli

description

wp package install wp-cli/doctor-command --allow-root

description

wp cron event run --all wp doctor list --allow-root

description

wp doctor check autoload-options-size --allow-root

Errors when there’s an excess of 10 duplicate cron jobs registered.

wp doctor cron-duplicates --allow-root

Errors when there’s an excess of 50 cron jobs registered.

wp doctor cron-count --allow-root&amp;amp;lt;/p&amp;amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Checks files on the filesystem for regex pattern `eval(.*base64_decode(.*`.

wp doctor check file-eval --allow-root&amp;amp;lt;/p&amp;amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Warns when a PHP file is present in the Uploads folder.

wp doctor check php-in-upload --allow-root&amp;amp;lt;/p&amp;amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp doctor check autoload-options-size --allow-root&amp;amp;lt;/p&amp;amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp doctor check cron-duplicates --allow-root&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Errors when there’s an excess of 50 total cron jobs registered.

wp doctor check cron-count

Verifies WordPress files against published checksums; errors on failure.

wp doctor check core-verify-checksums--allow-root&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp package install wp-cli/doctor-command --allow-root php -d memory_limit=512M &amp;amp;quot;$(which wp)&amp;amp;quot; package install trepmal/wp-revisions-cli&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp package install git@github.com:wp-cli/doctor-command.git php -d memory_limit=512M &amp;amp;quot;$(which wp)&amp;amp;quot; package install trepmal/wp-revisions-cli --allow-root&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp doctor list --allow-root&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Warns when autoloaded options size exceeds threshold of 900 kb

wp doctor check autoload-options-size --allow-root&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp db query &amp;amp;quot;SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM $(wp db prefix --allow-root)options WHERE autoload='yes' UNION SELECT 'autoloaded data count', count(*) FROM $(wp db prefix --allow-root)options WHERE autoload='yes' UNION (SELECT option_name, length(option_value) FROM $(wp db prefix --allow-root)options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 10)&amp;amp;quot; --allow-root&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp profile hook --all --spotlight --url=https://example.com/ --orderby=time --allow-root&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp cron event run Runs the next scheduled cron event for the given hook.&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp cron event run [...] [--due-now] [--all] OPTIONS [...] One or more hooks to run. [--due-now] Run all hooks due right now. [--all] Run all hooks. ==== === ==== define( 'WP_HOME', 'https://www.example.org' ); define( 'WP_SITEURL', 'https://www.example.org' ); https://www.example.org wp-cli is a super useful shell tool. Smokehouse LLC&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace ' Smokehouse LLC' ' Smokehouse Inc' --skip-columns=guid&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'example.com' 'example.org' --skip-columns=guid&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'example.dev' 'example.com' --skip-columns=guid Or, if you only want to change the option, you can do:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp option update home 'http://example.com'&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp option update siteurl 'http://example.com'&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp rewrite flush (permalinks)&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp rewrite structure (permalinks)&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp option get permalink_structure&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp option update permalink_structure '/%postname%' ===== Purging Cache In this example, object caching is enabled on the site on our Managed WordPress or Managed WooCommerce, if you need to clear the object cache, use:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp cache flush Regenerate Thumbnail Images If you changed the theme you were using on your site (which might be setting different image sizes), or if you changed the product image sizes in WooCommerce but now need to regenerate all thumbnail images, you can run this command:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp media regenerate --yes&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Delete post revisions

wp post delete $(wp post list --post_type='revision' --format=ids) --force&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

If you need to delete any of this temporary data, you can remove it from your database by running the following command

wp comment delete $(wp comment list --status=spam --format=ids&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Removing Temp Data from Database Expired transients can build up if you have a WooCommerce store. :

wp transient delete --expired&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Optimizing a Database If you want to optimize your site database, you can run this command:

wp db optimize Deleting Posts in Trash If you wanted to delete all posts that are in the trash, only run this command if you have moved posts to the trash, then you could run this command:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Deleting Posts in Draft Status If you did need to delete all posts that are set as draft

wp post delete $(wp post list --post_status=draft --format=ids)&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp db export You can now use gzip to compress the resulting sql file which will mean a smaller file being stored on your server: gzip sitebackup.sql Cleaning Up Your Post Revisions To delete post all revisions (moving them temporarily into the trash), use this WP-CLI command:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp post delete $(wp post list --post_type='revision' --format=ids) To delete the post revisions which have been moved to the trash (this includes all post revisions which have a post status of trash), run this command:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

If you wanted to delete all post revisions

wp revisions clean -1&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

If you wanted to delete all post revisions before a specific date, you can include that in the command. For example:

wp revisions clean --before-date=2019-06-10

Delete revisions of post type product

wp revisions clean --post_type=product&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

To list all existing post revisions, you can run this command:

wp revisions list&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

The wp-sec package is probably something that every WordPress developer should be running regularly on every site they manage, probably with a CRON job that greps the output and emails you when it indicates a vulnerability.

wp wp-sec check&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'http://old-domain.com/' 'http://new-domain.com/' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace ' CATEGORY DESCRIPTION' '' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'j6v.09c.myftpupload.com' 'dedianaelderlaw.com' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'http://www.w3.org' 'https://www.w3.org' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'http://kennywhitesports.com/' 'https://www.kennywhitesports.com/' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'name,tags,price,add-to-cart' 'name,description,price,add-to-cart' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'https://bardines.com/wp-content/' '/wp-content/' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'https://mybetterbuddy.com/wp-content/' '/wp-content/' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'https://ynz.0af.myftpupload.com/wp-content/uploads/' '/wp-content/uploads/' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'http://example.com/wp-content/' '/wp-content/' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'example.dev' 'example.com' --skip-columns=guid&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace woo_wpmudev_host www_kennywhitesports.com –-dry-run&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp eval 'acf_pro_update_license(&amp;amp;quot;PUT_YOUR_KEY_HERE&amp;amp;quot;);' /home/customer/www/therapy.skywaywebsolutions.com/public_html/wp-content/plugins&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin install /home/customer/www/therapy.skywaywebsolutions.com/public_html/wp-content/plugins/all-in-one-wp-migration.zip --activate&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp ai1wm backup --exclude-muplugins --exclude-cache ======== nice database backup:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp ai1wm backup --exclude-media --exclude-themes --exclude-inactive-themes --exclude-muplugins --exclude-plugins --exclude-inactive-plugins --exclude-cache delete inactive plugins&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin delete $(wp plugin list --status=inactive --field=name)&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp ai1wm backup --exclude-inactive-themes --exclude-cache Do a backup Install the plugin&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin install all-in-one-wp-migration --activate --force=yes Overwrite existing plugins if installed --activate=yes Activate the plugins --network=yes Network activate all&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin install all-in-one-wp-migration --force=yes --activate=yes You must reload the page once before continuing Do the backup Adjust the settings for your own need, this here makes a backup of the database only. I suggest using rsync to sync media files.&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp ai1wm backup --exclude-media --exclude-themes --exclude-inactive-themes --exclude-muplugins --exclude-plugins --exclude-inactive-plugins --exclude-cache Remove the plugin&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin deactivate all-in-one-wp-migration --uninstall&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin deactivate wonderplugin-lightbox-trial --uninstall&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin deactivate wonderplugin-pdf-embed --uninstall&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Restore a backup Go to backup directory or create if does not exist cd wp-content/ai1wm-backups/ Download the backup wget http://siteurl.fi/wp-content/ai1wm-backups/backup-20180105-142530-313.wpress

wp plugin deactivate youtube-subscribe-button --uninstall&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Install the plugin – You must reload the page once before continuing

wp plugin install all-in-one-wp-migration --activate&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Restore the site from backup

wp ai1wm restore backup-20180105-142530-313.wpress&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Equivalent of Saving Permalinks

wp rewrite flush&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

Remove the plugin and delete the backup file

wp plugin deactivate all-in-one-wp-migration --uninstall&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br /> &amp;amp;lt;/p&amp;amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin Manages plugins, including installs, activations, and updates. Installing multiple plugins To install multiple plugins here’s an example that downloads and activates 3 plugins: https://downloads.wordpress.org/plugin/meks-quick-plugin-disabler.zip # Install multiple plugins&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin install meks-quick-plugin-disabler --activate&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin update --all&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

# Update plugin

wp wc update&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin update &amp;amp;quot;plugin-name&amp;amp;quot; Activate, deactivate and delete a plugin: # Activate plugin $&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin activate hello&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

# Deactivate plugin

wp plugin deactivate hello Plugin 'hello' deactivated. Success: Deactivated 1 of 1 plugins. # Delete plugin $&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin delete hello Deleted 'hello' plugin. Success: Deleted 1 of 1 plugins. Get a list of plugins:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin list For example if you want to see only a list of all active plugins which have updates available, you can use:&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp plugin list --field=name --status=active --update=available&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

This is a useful command that searches/replaces strings in the database. e.g.: replacing and old domain name with a new domain name. Before running this command we strongly recommend you to do a backup for your database

wp search-replace 'http:' 'https:' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'http://gplpartnership.com/' 'http://www.example.org/' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'https://bardines.com/products/' 'https://zg3.786.myftpupload.com/our-products/' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'secureservercdn.net/198.71.233.47/ynz.0af.myftpupload.com' 'ynz.0af.myftpupload.com' --precise --recurse-objects --all-tables-with-prefix&amp;lt;br /&amp;gt;&lt;br /&gt;<br /><br />

description

wp search-replace 'https://example.org' 'https://www.example.org' --precise --recurse-objects --all-tables-with-prefix

# List users

wp user list

# List users with administrator role

wp user list --role=administrator

Create a new user # Create a new administrator user

wp user create jonathanbrown jo.natha.nbrown@gmail.com --role=administrator

Create a new author user

wp user create john john@smith.com --role=author

You can reinstall WordPress core using WP-CLI. The following command would download WordPress core without the default themes and plugins

wp core download --skip-content --force

To regenerate all thumbnails for all images inside your WordPress media library, you can use the following command

wp media regenerate --yes

You can regenerate thumbnails for only the missing image sizes using the –only-missing option like this>/h6>

wp media regenerate --only-missing