wp post list
Overview
Query and filter any post type by status, author, date, taxonomy, and more. Output in multiple formats for auditing, reporting, and feeding IDs into bulk operations.
What It Does
wp post list runs a WP_Query with the provided arguments and formats the results. Every supported WP_Query parameter can be expressed as a flag.
Syntax
wp post list [OPTIONS]
Common Options
| Flag | Description |
|---|---|
--post_type=TYPE | Post type(s), comma-separated (default: post) |
--post_status=STATUS | publish, draft, trash, any |
--author=LOGIN | Filter by author login |
--fields=FIELDS | Fields to show (comma-separated) |
--field=FIELD | Return one field per line (for scripting) |
--format=FORMAT | table, json, csv, ids, count |
--orderby=FIELD | date, title, ID, modified |
--order=ASC_OR_DESC | Sort direction |
--posts_per_page=N | Max results (default: unlimited) |
--category=SLUG | Filter by category |
--tag=SLUG | Filter by tag |
--s=SEARCH | Search keyword |
Basic Usage
List all posts
wp post list
List published pages
wp post list --post_type=page --post_status=publish
Get post IDs only (for scripting)
wp post list --post_status=draft --field=ID
Export as JSON
wp post list --format=json --post_type=post > posts.json
Count posts
wp post list --post_type=post --post_status=publish --format=count
Real-World Scenarios
Scenario 1: Audit all drafts
wp post list \
--post_status=draft \
--post_type=post \
--fields=ID,post_title,post_date,post_author \
--format=table
Scenario 2: Find posts with no category
wp post list \
--post_type=post \
--post_status=publish \
--fields=ID,post_title \
--format=table \
--cat=-1
Scenario 3: Get all product IDs for bulk update
PRODUCT_IDS=$(wp post list --post_type=product --post_status=publish --field=ID)
for id in $PRODUCT_IDS; do
wp post meta update "$id" _featured "yes"
done
Scenario 4: Export published posts to CSV for review
wp post list \
--post_type=post \
--post_status=publish \
--fields=ID,post_title,post_date,post_author \
--format=csv > published-posts.csv
Quick Reference
wp post list # All posts
wp post list --post_type=page --post_status=publish
wp post list --field=ID # IDs for scripting
wp post list --format=count # Count only
wp post list --format=csv > posts.csv
Next Steps
wp post get— inspect a single post.wp post update— bulk update matched posts.wp post delete— bulk delete matched posts.