If you aren’t already using WP-CLI, start using it now. WP-CLI makes your day-to-day WordPress workflows easier. Some of my favorite WP-CLI commands are:
wp install plugin plugin-slug – automatically install the plugin on your site. For example, if you want to install the WPForce Logout plugin, then simply run
wp install plugin wp-force-logout. You don’t have to download or search for the plugin to install.
wp activate plugin plugin-slug – automatically activate the plugin.
3) wp eval – enter the PHP code from within the command line. Examples:
wp eval 'echo rand();' --skip-wordpress
generates a random number.
--skip-wordpress to execute code without loading WordPress.
wp eval 'echo get_option("last_login");'
generates the value of last_login stored in the options table.
wp i18n make-pot – creates a pot file for the plugin. Go to the plugin’s directory and enter the command
wp i18n make-pot . languages/plugin-slug.pot
wp user – manages user data.
wp user create ram firstname.lastname@example.org --role=administrator – creates a user.
wp user delete ram – deletes a user ram. You can pass user login, user email, or user ID.
wp user list – list all users.
wp scaffold – creates a scaffold plugin or theme. Along with the tests. How cool.
wp scaffold plugin sample-plugin – creates a Sample Plugin in the
wp-content/plugins directory. Start building an awesome plugin.
wp config edit – instantly edit the wp-config.php. The file will automatically open for you to edit.
wp option – manages options in wp_options DB table.
wp option delete wpfda_review_notice_dismissed – deletes the option “wpfda_review_notice_dismissed” which helps to re-display the review notice for WP Frontend Delete Account plugin.
wp post – manages the WordPress posts.
wp post create --post-title=All In One Music Player Test --post-content=No music player selected.
wp delete post 22 --force – deletes the post ID 22, force deletes the post by skipping trash.