Skip to main content

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​

FlagDefaultDescription
--count=N100Number of posts to generate
--post_type=TYPEpostPost type slug
--post_status=STATUSpublishPost status
--post_author=ID1Author user ID
--post_date=DATEnowDate for all generated posts
--max_depth=N1For hierarchical types (pages), depth of child nesting
--format=FORMATprogressprogress, 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​

  1. Only use on staging/dev — generated posts pollute production content.
  2. Use --format=ids to capture IDs for follow-up operations.
  3. Clean up after testing with a bulk delete using the same --post_type filter.

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​