Change the status of many posts
wp_bulk_update_statusUpdate the status of up to 500 posts, pages, or media files at once by ID list to publish, draft, pending, private, or trash, with unknown IDs skipped and per-post results returned.
Instructions
Change the status of many posts at once by id list (posts, pages, other post types and media files alike) to publish, draft, pending, private or trash; at most 500 ids per call (over_limit counts the rest, which are not touched). Suited to batches; one post's status and other fields change with wp_update_post. Unknown ids are skipped, posts already in the status are left as they are and an id given twice counts once, so a repeated call changes nothing more, except where WordPress stores another form than asked (stored_as below): those posts are written again. Publishing makes posts public at once. On a site without a trash, "trash" is refused, since WordPress would delete for good. A media file set to draft, pending or publish becomes "inherit" (shown wherever its parent is published, everywhere without one), which needs the right to publish. Returns updated (the count); ids, the posts that have the status now, with stored_as where WordPress stores a form of its own ("future" for a post dated ahead, "inherit" for a file); failed, each with the status it has (null if unreadable) and, where telling, an error: update_failed, trash_refused or untrash_refused (refused by WordPress or a plugin), unreadable (nothing written) or unverified (written, not readable back); forbidden, the posts the account may not change (edit right per post, delete right for trash). failed and forbidden list 100 each; failed_omitted and forbidden_omitted count the rest. undo is the token of an undo point with the previous statuses, for wp_undo (null when none was recorded). A call begins no further post once the request has run 60 seconds (the first post is always handled, and one already begun is finished), so a long list is answered in parts; remaining lists the ids it did not reach, in their order (empty when it reached all), and those ids, sent in a further call, continue where it stopped, with an undo point of their own. Needs edit_others_posts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ids | Yes | Post ids (integers) of any post type. An id given twice counts once; ids beyond the first 500 are not touched, nor those a call does not reach in its time (remaining). | |
| status | Yes | Target status: publish, draft, pending, private or trash; any other value is refused and nothing changes. |