Skip to main content

wp post update

Overview

Modify any field on an existing post — title, content, status, author, date, and more. Accepts one or more post IDs, enabling bulk updates in a single command.

What It Does

wp post update calls wp_update_post() on the specified post(s). You can update any post field that wp_insert_post() accepts.

Syntax

wp post update <id>... [--<field>=<value>]

Common Options

FlagDescription
--post_title=TITLENew title
--post_content=CONTENTNew body content
--post_status=STATUSpublish, draft, trash, private, pending
--post_author=IDNew author user ID
--post_date=DATENew date: YYYY-MM-DD HH:MM:SS
--post_name=SLUGNew URL slug
--post_parent=IDNew parent post ID
--comment_status=STATUSopen or closed
--ping_status=STATUSopen or closed

Basic Usage

Update a post's status

wp post update 42 --post_status=publish

Change the title and slug

wp post update 42 --post_title="Updated Title" --post_name="updated-title"

Bulk update — publish multiple drafts

wp post update 12 15 22 --post_status=publish

Update content from a file

wp post update 42 /path/to/new-content.html

Real-World Scenarios

Scenario 1: Publish all pending posts

for id in $(wp post list --post_status=pending --post_type=post --field=ID); do
wp post update "$id" --post_status=publish
done

Scenario 2: Bulk reassign author

# Reassign all posts from author 5 to author 1
for id in $(wp post list --author=5 --field=ID --post_status=any); do
wp post update "$id" --post_author=1
done

Scenario 3: Close comments on old posts

# Close comments on posts older than 2024
for id in $(wp post list --post_type=post --after=2000-01-01 --before=2024-01-01 --field=ID); do
wp post update "$id" --comment_status=closed
done

Scenario 4: Change post date for scheduled content

wp post update 88 --post_date="2026-04-01 09:00:00" --post_status=future

Best Practices

  1. Always verify IDs with wp post list before bulk updates.
  2. Back up firstwp db export — before bulk status changes.
  3. Use wp post list --fields=ID,post_title,post_status to preview what you'll update.

Quick Reference

wp post update <id> --post_status=publish
wp post update <id> --post_title="New Title"
wp post update 12 15 22 --post_status=publish # Bulk
wp post update <id> --post_author=<user_id>

Next Steps