Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ernilambar/wp-cli-tips
WP-CLI tips and tricks
https://github.com/ernilambar/wp-cli-tips
wp-cli
Last synced: 17 days ago
JSON representation
WP-CLI tips and tricks
- Host: GitHub
- URL: https://github.com/ernilambar/wp-cli-tips
- Owner: ernilambar
- Created: 2017-01-30T08:12:17.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2024-09-09T04:58:54.000Z (about 2 months ago)
- Last Synced: 2024-10-03T11:14:57.433Z (about 1 month ago)
- Topics: wp-cli
- Size: 5.86 KB
- Stars: 12
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WP CLI- Tips
WP-CLI tips and tricks### Comments
##### Empty trash.
```
wp comment delete $(wp comment list --status=trash --format=ids)
```##### Approve all pending comments.
```
wp comment approve $(wp comment list --status=hold --format=ids)
```##### Delete all spam comments.
```
wp comment delete $(wp comment list --status=spam --format=ids)
```##### Mark all pending comments as spam.
```
wp comment spam $(wp comment list --status=hold --format=ids)
```### Media
##### Regenerate all thumbnails that have attachment IDs between 1000 and 2000.
```
seq 1000 2000 | xargs wp media regenerate
```##### Regenerate all thumbnails that are set as Featured Image in pages.
```
wp media regenerate --yes $(wp post list --post_type=page --post_status=publish --format=ids | xargs -d ' ' -I % wp db query 'SELECT meta_value FROM wp_postmeta WHERE post_id=% AND meta_key="_thumbnail_id"' --skip-column-names)
```##### Import all jpgs in the current user's "Pictures" folder.
```
wp media import ~/Pictures/**\/*.jpg
```##### Import a local image and set it to be the post thumbnail for a post.
```
wp media import ~/Pictures/himalaya.jpg --post_id=123 --title="Himalaya range" --featured_image
```### Custom CSS
##### Remove Custom CSS Post of all themes.
```
wp post delete $(wp post list --post_type=custom_css --format=ids)
```##### Remove Custom CSS Post of a theme.
```
wp post delete $(wp post list --name=blue-planet --post_type=custom_css --format=ids)
```##### Remove Custom CSS Post of currently active theme.
```
wp post delete $(wp post list --name=$(wp option get stylesheet) --post_type=custom_css --format=ids)
```### Options
##### Disable avatar.
```
wp option set show_avatars 0
```##### Delete all options begining with "theme_mods_".
```
wp option list --search="theme_mods_*" --field=option_name | xargs -I % wp option delete %
```##### Delete all widget instances.
```
wp option list --search="widget_*" --field=option_name | xargs -I % wp option delete %
```### Widgets
##### Delete all inactive widgets.
```
wp widget delete $(wp widget list wp_inactive_widgets --format=ids)
```##### Move all widgets from "sidebar-1" to "sidebar-2" maintaining widget order.
```
printf "%s\n" $(wp widget list sidebar-1 --format=ids)|tac | xargs -I % wp widget move % --sidebar-id=sidebar-2
```