Skip to main content

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

FlagDescription
--post_type=TYPEPost type(s), comma-separated (default: post)
--post_status=STATUSpublish, draft, trash, any
--author=LOGINFilter by author login
--fields=FIELDSFields to show (comma-separated)
--field=FIELDReturn one field per line (for scripting)
--format=FORMATtable, json, csv, ids, count
--orderby=FIELDdate, title, ID, modified
--order=ASC_OR_DESCSort direction
--posts_per_page=NMax results (default: unlimited)
--category=SLUGFilter by category
--tag=SLUGFilter by tag
--s=SEARCHSearch 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