Web development | Posted on January 7, 2017

So far i didn’t find any propper WordPress command line tool a,ka wp-cli cheat sheet.As i use WordPress command line tools  time to time , i think it’s pretty handy to collect list of commands.So i started to collect all these commands in one place. If anyone have something to add to this list write it down in comments.

Update: Added wp core config example

Download wordpress

wp core download

Generate wp-config.php file.

wp core config --dbname=<dbname> --dbuser=<dbuser> --dbpass=<dbpass> --dbprefix=<dbprefix>

Install wordpress

wp core install --url="your_domain_name"  --title="Your Blog Title" --admin_user="admin" --admin_password="your_password" --admin_email="your_email"

Search plugin.

wp plugin search yoast

As response we will get
Success: Showing 10 of 282 plugins.
+---------------------------------------------+--------------------------------------------+--------+
| name                                        | slug                                       | rating |
+---------------------------------------------+--------------------------------------------+--------+
| Yoast SEO                                   | wordpress-seo                              | 82     |
| Yoast SEO & qTranslate-X                | wp-seo-qtranslate-x                        | 82     |
| All Meta Stats Yoast SEO Addon              | all-meta-stats-yoast-seo-addon             | 100    |
| Import Settings into WordPress SEO by Yoast | yoast-seo-settings-xml-csv-import          | 100    |
| Remove Branding for Yoast SEO               | remove-branding-for-yoast-seo              | 74     |
| Surbma - Yoast Breadcrumb Shortcode         | surbma-yoast-breadcrumb-shortcode          | 80     |
| Meta Box for Yoast SEO                      | meta-box-yoast-seo                         | 0      |
| Meta Description Stats Addon for Yoast SEO  | meta-description-stats-addon-for-yoast-seo | 100    |
| Keyword Stats Addon for Yoast SEO           | keyword-stats-addon-for-yoast-seo          | 100    |
| Title Stats Addon for Yoast SEO             | title-stats-addon-for-yoast-seo            | 100    |
+---------------------------------------------+--------------------------------------------+--------+

 

Install plugin

wp plugin install pluginname   example wp plugin install hello-dolly

list plugins

wp plugin list +——————–+———-+———–+————+ | name | status | update | version | +——————–+———-+———–+————+ | portfolio | inactive | available | 0.1 | | developer | active | none | 1.2.6 | | log-viewer | active | none | 14.05.04 | | shareaholic | active | none | 7.7.1.0 | | theme-check | active | none | 20151211.1 | | wordpress-importer | active | none | 0.6.1 | +——————–+———-+———–+————+

List installed themes

wp theme list

Search for new themes

wp theme search keyword expample wp theme search boot

As response we will get

+---------------------+---------------------+--------+
| name                | slug                | rating |
+---------------------+---------------------+--------+
| Bootstrap Four      | bootstrap-four      | 0      |
| BootFrame Core      | bootframe-core      | 100    |
| Bootville Lite      | bootville-lite      | 100    |
| bootcake            | bootcake            | 100    |
| Simple Bootstrap    | simple-bootstrap    | 0      |
| Bootstrap Canvas WP | bootstrap-canvas-wp | 86     |
| boot_Strap          | boot_strap          | 64     |
| WPBoot              | wpboot              | 100    |
| boots               | boots               | 20     |
| Flat Bootstrap      | flat-bootstrap      | 100    |
+---------------------+---------------------+--------+

Install theme

wp theme install bootstrap-four

We identify theme by its slug
Activate theme

wp theme activate bold-headline

List posts

wp post list

Edit post

wp post edit 1

Post update

wp post update 1 --post_title="New title..."

Create posts

wp post create --post_status=publish --post_title="Second Post" --edit

Login wordpress db

wp db cli

List wordpres users

wp db query "SELECT user_login,ID FROM wp_users;"

Change wordpress post author

wp post update 6 --post_author=1

Optimize db

wp db optimize

Update WordPress

wp core update

Update wordpress DB

wp core update-db

Update all plugins

wp plugin update --all

Tags: