Useful wp cli commands for every WordPress Developer. This repo will contain all the useful commands that help WordPress developer to speed up the development process.For complete list please refer official wp-cli documentation.
# With Phar file
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
#and
php wp-cli.phar --info
#and
chmod +x wp-cli.phar
#and
sudo mv wp-cli.phar /usr/local/bin/wp
π² wp core version
4.9.7
π² wp --info
/var/www/html/wordpress ξ° wp --info
OS: Linux 4.13.0-45-generic #50~16.04.1-Ubuntu SMP Wed May 30 11:18:27 UTC 2018 x86_64
Shell: /usr/bin/zsh
PHP binary: /usr/bin/php7.0
PHP version: 7.0.30-0ubuntu0.16.04.1
php.ini used: /etc/php/7.0/cli/php.ini
WP-CLI root dir: phar://wp-cli.phar
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /var/www/html/wordpress
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 1.5.1
π² wp plugin list
/var/www/html/wordpress ξ° wp plugin list
+---------+----------+-----------+---------+
| name | status | update | version |
+---------+----------+-----------+---------+
| akismet | inactive | available | 4.0.3 |
| hello | inactive | none | 1.7 |
+---------+----------+-----------+---------+
π² wp plugin activate plugin_name ( see the name from plugin list as shown in above command)
/var/www/html/wordpress ξ° wp plugin activate hello
Plugin 'hello' activated.
Success: Activated 1 of 1 plugins.
/var/www/html/wordpress ξ° wp plugin status hello
Plugin hello details:
Name: Hello Dolly
Status: Active
Version: 1.7
Author: Matt Mullenweg
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
π² wp plugin install woocommerce --activate
/var/www/html/wordpress ξ° wp plugin install woocommerce --activate
Installing WooCommerce (3.4.3)
Downloading installation package from https://downloads.wordpress.org/plugin/woocommerce.3.4.3.zip...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Activating 'woocommerce'...
Plugin 'woocommerce' activated.
Success: Installed 1 of 1 plugins.
π² wp user create username useremail --role=rolename
/var/www/html/wordoress ξ° wp user create inrsaurabh [email protected] --role=author
Success: Created user 2.
Password: a$hgLg3HeZJsy%sOnsZG!qes
π² wp user update user_id --user_pass=new_password
/var/www/html/wordoress ξ° wp user update 2 --user_pass=your_new_password
Success: Updated user 2.
π² wp theme list
/var/www/html/wordpress ξ° wp theme list
+-----------------+----------+--------+---------+
| name | status | update | version |
+-----------------+----------+--------+---------+
| twentyfifteen | inactive | none | 2.0 |
| twentyseventeen | active | none | 1.6 |
| twentysixteen | inactive | none | 1.5 |
+-----------------+----------+--------+---------+
π² wp theme activate themename ( see name from above list)
/var/www/html/wordpress ξ° wp theme activate twentysixteen
Success: Switched to 'Twenty Sixteen' theme.
π² wp scaffold child-theme child-theme-name --parent_theme=parentthemename ( see name from above list)
/var/www/html/wordpress ξ° wp scaffold child-theme twentysixteen-child --parent_theme=twentyseventeen
Success: Created '/var/www/html/wordpress/wp-content/themes/twentysixteen-child'.
π² wp theme delete themename ( see name from above list)
/var/www/html/wordpress ξ° wp theme delete **themename**
Deleted '**themename**' theme.
Success: Deleted 1 of 1 themes.
π² wp rewrite flush
/var/www/html/wordpress ξ° wp rewrite flush
Success: Rewrite rules flushed.
π² wp db check
/var/www/html/wordpress ξ° wp db check
db_name.prefix_tableName OK
wppwa.wppwa_comments OK
...................................
..................................
Success: Database checked.
π² wp search-replace 'http://localhost/projectname' 'http://projectname.com' --skip-columns=guid
/var/www/html/wordpress ξ° wp search-replace 'http://localhost/projectname' 'http://projectname.com' --skip-columns=guid
+---------------------+-----------------------+--------------+------+
| Table | Column | Replacements | Type |
+---------------------+-----------------------+--------------+------+
| wppwa_commentmeta | meta_key | 0 | SQL |
| wppwa_commentmeta | meta_value | 0 | SQL |
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
wppwa_options | option_value | 2 | PHP |
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
| wppwa_users | user_activation_key | 0 | SQL |
| wppwa_users | display_name | 0 | SQL |
+---------------------+-----------------------+--------------+------+
Success: Made 8 replacements.
- mkdir blog
- cd blog
- wp core download
- wp core config --dbhost=your_host_name --dbname=db_prefix --dbuser=username --dbpass=password
- wp core install --url=yourwebsite.com --title="Your Blog Title" --admin_name=wordpress_admin_name --admin_password=admin_pwd [email protected]
- chmod 644 wp-config.php
- chmod 775 uploads/
To use next 3 commands include these commands in your theme.
- wp option update start_of_weeks 0
- wp option delete start_of_weeks
- wp option add option_name option_value
- wp plugin list --update=available
- wp post delete $(wp post list --post_type='property' --format=ids) --force
Please Download, Fork, & Commit to add more helpful commands.