wp post get
Overview
Inspect all fields of a single post, page, or custom post type. Use this before updating, when scripting conditional logic, or when auditing specific content items.
What It Does
wp post get fetches a single post record using get_post() and displays all standard fields. A single --field extracts one value for use in scripts.
Syntax
wp post get <id> [OPTIONS]
Arguments & Options
| Flag | Description |
|---|---|
--field=FIELD | Return a single field value |
--fields=FIELDS | Comma-separated list of fields |
--format=FORMAT | table, json, yaml, csv |
Basic Usage
Get all fields for a post
wp post get 42
Get a single field
wp post get 42 --field=post_status
Get as JSON
wp post get 42 --format=json
Real-World Scenarios
Scenario 1: Check status before publishing
STATUS=$(wp post get 42 --field=post_status)
if [[ "$STATUS" == "draft" ]]; then
wp post update 42 --post_status=publish
echo "Post 42 published."
fi
Scenario 2: Get post slug for URL verification
SLUG=$(wp post get 42 --field=post_name)
SITEURL=$(wp option get siteurl)
echo "Post URL: ${SITEURL}/${SLUG}/"
Scenario 3: Verify post author before bulk reassignment
AUTHOR_ID=$(wp post get 55 --field=post_author)
echo "Post 55 is authored by user ID: $AUTHOR_ID"
Quick Reference
wp post get <id> # All fields
wp post get <id> --field=post_status # Single field
wp post get <id> --field=post_title
wp post get <id> --format=json
Next Steps
wp post update— modify fields after inspection.wp post meta— get custom meta fields for the post.wp post list— find posts to inspect.