Commands:
These are all unix-based;
(I put these into my .bashrc of ~/ my dev environments and then run source ~/.bashrc
to ensure they are used)
(for reference, in unix, $1 is the first argument)
- Install a plugin and immediately activate it:
plugme() { wp plugin install $1 --activate }
For example plugme classic-editor
would immediately install the plugin and activate it on your site.
- Change the activation status of an plugin in a wordpress installation. Very helpful for troubleshooting and want to determine if a behaviour is repeatable when a plugin is active or inactive.
e.g.
deplugme query-monitor
will deactivate an activated/active query-monitor plugin type it once more; and the plugin will be reactivated.
deplugme() { wp plugin toggle $1 }
- Deactivates and uninstalls a plugin (helpful when I want to get rid of a plugin after I try it out, dislike it, want to get rid of it)
unplugme() { wp plugin uninstall $1 --deactivate }
- switch to another theme:
totheme() { wp theme activate $1 }
so, entering totheme twentytwentyfive
will change the active theme to twentytwentyfive
- delete and trash a post (argument is the post_id)
trash() { wp post delete $1 --force }
- empty the trash, specify the post_type b/c if you don't, wp-cli will only delete post types 'posts'
trashempty() { wp post delete $(wp post list --post_type=page,post,your_custom_post_type --post_status=trash --format=ids) }
alias recentedits="wp post list --post_type=post,page,name_of_your_custom_post_type --orderby=modified --order=DESC --fields=ID,post_title,post_date,post_modified --posts_per_page=10"
typing recentedits
will return the list of last 10 recently edited pieces of content on your website