WP-CLI post commands let you list, create, update, and delete WordPress posts and pages from the terminal. This is useful for bulk operations, content audits, and fixing post status issues that would be tedious through the WordPress dashboard.
Command reference
| Command | What it does |
|---|---|
wp post list | Lists posts (defaults to published posts) |
wp post list --post_type=page | Lists pages instead of posts |
wp post list --post_status=draft | Lists all draft posts |
wp post list --post_status=trash | Lists posts in the Trash |
wp post list --fields=ID,post_title,post_status | Lists posts showing only specific fields |
wp post get <id> | Shows full details of a specific post by ID |
wp post create --post_title='Test' --post_status=draft | Creates a new draft post |
wp post update <id> --post_status=publish | Changes a post's status to published |
wp post delete <id> | Moves a post to the Trash |
wp post delete <id> --force | Permanently deletes a post (bypasses Trash and cannot be undone) |
wp post meta get <id> <meta-key> | Gets a specific piece of post metadata |
wp post meta update <id> <meta-key> '<value>' | Sets a post metadata value |
Bulk-deleting spam posts
If your site has accumulated spam posts, you can list and delete them all at once.
- List posts in spam status to review them:
wp post list --post_status=spam
- If you are satisfied these should all be removed, delete them permanently:
wp post delete $(wp post list --post_status=spam --format=ids) --force
Warning about permanent deletion
The --force flag permanently deletes posts, bypassing the Trash. Without --force, posts are moved to the Trash instead, which is safer and allows recovery. Always use without --force unless you are certain you want permanent deletion.
Need help?
If you have questions about managing posts and content, visit our support page or email hello@smarthost.ie.
Frequently asked questions
How do I list all my pages instead of posts?
Add --post_type=page to your command. For example: wp post list --post_type=page.
What is the difference between wp post delete and wp post delete --force?
Without --force, the post moves to the Trash and can be recovered. With --force, it is permanently deleted and cannot be recovered.
Can I create a page with WP-CLI?
Yes. Use wp post create --post_title='My Page' --post_type=page --post_status=publish to create and publish a page immediately.
Last updated: 25 March 2026
