wp post generate
Overview
Create many test posts at once with randomized titles and placeholder content. Perfect for populating staging environments, testing pagination, and validating theme layouts.
What It Does
wp post generate creates N posts with generated content, assigning them to a specific post type and status. All generated posts have the same author and status.
Syntax
wp post generate [OPTIONS]
Arguments & Options
| Flag | Default | Description |
|---|---|---|
--count=N | 100 | Number of posts to generate |
--post_type=TYPE | post | Post type slug |
--post_status=STATUS | publish | Post status |
--post_author=ID | 1 | Author user ID |
--post_date=DATE | now | Date for all generated posts |
--max_depth=N | 1 | For hierarchical types (pages), depth of child nesting |
--format=FORMAT | progress | progress, ids |
Basic Usage
Generate 20 published posts
wp post generate --count=20
Generate draft pages for UI testing
wp post generate --count=10 --post_type=page --post_status=draft
Generate and capture IDs
wp post generate --count=5 --format=ids
Real-World Scenarios
Scenario 1: Stress test pagination
wp post generate --count=500 --post_type=post --post_status=publish
wp post list --format=count
Scenario 2: Generate WooCommerce products for testing
wp post generate --count=50 --post_type=product --post_status=publish
Scenario 3: Generate posts and add meta
IDS=$(wp post generate --count=10 --format=ids)
for id in $IDS; do
wp post meta add "$id" _test_flag "1"
done
Scenario 4: Cleanup generated content after testing
wp post delete $(wp post list --post_type=post --field=ID) --force --defer-term-counting
Best Practices
- Only use on staging/dev — generated posts pollute production content.
- Use
--format=idsto capture IDs for follow-up operations. - Clean up after testing with a bulk delete using the same
--post_typefilter.
Quick Reference
wp post generate --count=20
wp post generate --count=50 --post_type=page --post_status=draft
wp post generate --count=10 --format=ids
Next Steps
wp post delete— bulk remove generated test content.wp post list— verify generated posts.