As a PC user you have probably got used to the command line, you’ve seen how easy and fast it is to do stuff that will normally take 3 or more steps. Well, one of the beauties of WordPress is that it can be controlled from the command line; perform tasks without having to navigate around on your web browser. These codes are simple to understand, and do not worry of messing up your WordPress website as any incorrect syntax will be ignored.
A2 Hosting offers a hosting plan that has many great features to make maintaining WordPress websites easier, including pre-installing WP-Cli for your website. When you purchase any of the Managed WordPress Hosting plans, you get a turbo-speed server, daily backup, premium plugins and themes etc. There is 24/7 support and you will get your website migrated for free. These plans are relatively cheap, the basic; which is named “1-SITE” starts from $12.97USD, 3-SITES starting at $19.48USD and UNLIMITED starting from $37.97USD, all prices are paid monthly.
Setting up WP-Cli Commands is simple but many people still find it hard to do,
Note: the command that need to be typed are highlighted
List of WP-Cli Commands
Firstly, we are going to explore the list of available WordPress Cli commands and possible parameters where necessary. In future case where more commands may have been added to the list and you need to get it by yourself, just enter wp help or wp. Into the command line.
wp core [download|config|install|install_network|version|update|update_db]
wp db [create|drop|optimize|repair|connect|cli|query|export|import]
wp export [validate_arguments]
wp generate [posts|users]
wp option [add|update|delete|get]
wp plugin [activate|deactivate|toggle|path|update|uninstall|delete|status|install]
wp post-meta [get|delete|add|update]
wp post [create|update|delete]
wp theme [activate|path|delete|status|install|update]
wp transient [get|set|delete|type]
wp user-meta [get|delete|add|update]
wp user [list|delete|create|update]
Update WordPress with command line
First let us check the installed version via command line
wp core version
This version is obviously outdated, so we need to update it with the following command line
wp core update
Downloading update from http://wordpress.org/wordpress-3.5.1-new-bundled.zip…
Unpacking the update…
Success: WordPress updated successfully.
Install or activate WordPress Plugin and themes via command line
Installing, activating, uninstalling or deleting a WordPress plugin can be done with the following lines, just replace the Plugin_name with existing plugin name
wp plugin install Plugin_Name
wp plugin activate Plugin_Name
wp plugin uninstall Plugin_Name
wp plugin delete Plugin_Name
You can check the list of available plugin with
wp plugin status
Same can be done when dealing with themes, only the “plugin” will be replaced with “theme. Listing the available plugins;
wp theme status
Legend: I = Inactive, A = Active, U = Update Available
Then you can perform tasks with these lines;
wp theme install Plugin_Name
wp theme activate Plugin_Name
wp theme uninstall Plugin_Name
wp theme delete Plugin_Name
Working with posts
You can create post with the following command;
wp post create –post_type=page –post_status=publish –post_title=’My test post’ –post_content=’This is a test post’Success: Created post 4.
Delete a specific post with this command;
wp post delete 3 –forceSuccess: Deleted post 3.
A2 Hosting doesn’t stop at just Managed WordPress Hosting. Far from it! They offer a variety of services from standard shared web hosting, Fully Managed WordPress hosting (see above), Fully Managed VPS Hosting and more.