The WordPress site is a content management system which is preferred widely for creating a website. It is easy to use and handle with its graphical interface. In general, all the installs, updates, backups, etc., are performed from the admin panel after login. However, it can be done quicker from the command line with the WP-CLI tool. With this, you won’t have to login to the admin panel too.
Here Is The List Of Actions You Can Do With The WP-CLI:
1. Install WordPress Site
Installing a WordPress is now easy with the WP-CLI core install command. You will have to open the command prompt and input a simple command with the required parameters; URL, site title, admin username, admin password, admin email. The command you have to add is,
wp core install –url=” site name” –title=”Site Title” –admin_user=”login username” –admin_password=” login password” –admin_email=” admin email address”
Once it finishes configuring, it will display a message “Success: WordPress installed successfully”
2. Update WordPress
Keeping WordPress site up-to-date is important to increase the performance of your site. With every latest update, WordPress becomes more secure and come with patches for scripts. To do it via WP-CLI command is easier than you think. For updating your site to the latest version you will have to input the command “wp core update” and you will receive a success message once completed. Similarly, updating to a particular version can be done by giving the command as wp core update —version= “version number” and to go back the previous version, use the command wp core update —version= “version number” —force.
3. Install Themes
Creating a theme will be the priority for any website owner. Instead of doing it via control panel, you can also do it in the command line interface too. For this, first, you will have to check the list of themes installed in your site. By typing wp theme list in the command prompt, you will get the accurate list of themes which you are using currently. Now, if you wish to change the theme and looking for the available options, type wp theme search followed by the keyword for the theme. e.g.: fancy, bright, etc. This will display the relevant themes along with their ratings. Choose one and install it easily by typing wp theme install “name of the theme” and it will be successful.
4. Update Themes
Irrespective of the theme installed, it is necessary to update it on a regular basis to obtain the benefits of the theme with every latest update. Updating a theme takes a lot of time when done via Cpanel, the shortest and the quickest method of doing it is to open the command prompt and input wp theme status to check the list of themes that requires an update. Now give a command, wp theme update — all and it will update the theme to the latest version.
5. Install Plugins
Plugins help in creating an interactive interface to your site. Just like the themes, the plugins can also be installed with ease from the command line. To look at the list of plugins available input wp plugin list and look if they are active. If you are aware of the name of the plugin, input, wp plugin search “plugin keyword” and look for the slug name of the desired plugin. Now, input wp plugin install “plugin’s slug” and activate it by giving a command wp plugin activate “plugin slug”
6. Update Plugins
Similar to the themes, updating a plugin requires checking the current status of the plugin. In order to make it have a strong security link input wp plugin update –all and keep all your plugins up-to-date. In the off chance if you wish to simply update a single plugin, type wp plugin update “plugin name” and get your job done.
7. Manage Content
Managing content on a WordPress platform literally means editing or updating the post details. Instead of performing it the usual way, you can do it in the command line interface itself. In general, as soon as you open a WordPress account, you will get a default post titled, “hello world”. To edit this post you will have to first search it from the page by typing wp post list. Following this step, you can edit it by giving a command wp post edit 1 and manage the content by adding a content of your choice. The post title can be edited by typing wp post update 1 –post_title “content of your choice” Clicking save, will make changes to this file.
8. Manage Database
Interacting with the WordPress SQL can also be done right from the command line prompt. Simply type wp db cli and get into the MYSQL prompt. From this, you can perform database admin operations. Also, to exit from the database interface simply type exit in the command. Coming to querying the database, give a command, wp db query “SELECT user_login,ID FROM wp_users;” Same way, if your database requires optimizing, it can be done by giving a command, wp dp optimize.
9. Create A Sample Post
Creating posts in the WordPress blogs is really time-consuming. But, once you get comfortable to use this WP-CLI command, you will start creating the entire posts for the blog from the command line interface itself. If you wish to try creating a sample post, open the command line interface and type the following:
wp post create –post_type=page –post_status=publish –post_title= ‘My sample post’ –post_content= ‘This is a sample post ‘Success: Created post 5.
This will create a post titled my sample post in your page. In the same way, you can do it for all the original posts.
10. Delete A Post
If you consider removing a post from your page due to any reason, try doing it from the command line interface this time. The only thing you should be careful is to know the post number you wish to delete and mention it correctly in the command prompt. Else, you will end up deleting the wrong post. So, to delete a particular post, just type, wp post delete 4 –forceSuccess: deleted post 4. This will delete the post and move it to trash.