Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WP-CLI snippets

Delete all menus

wp menu list --format=ids | xargs wp menu delete

Delete posts of one type in bulk

wp post list --post_type='post-type-here' --format=ids | xargs wp post delete --force

Populate a custom field of a named post type with dummy data

wp eval "\$posts = get_posts( ['post_type' => 'post-type-here', 'numberposts' => -1 ] ); foreach ( \$posts as \$post ) { update_post_meta( \$post->ID, 'field-name-here', 'test' . \$post->ID . '@example.com' ); } echo 'Done!';"

Create lots of test sites under WP multisite

for i in {1..150}; do wp site create --slug="test$i"; done;

(If using fish, try switching shell first with sh.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment