How to Unarchive Content

See below for the ways you can remove content from the archive with the "unarchive" action.

The default behavior of any unarchive action is to restore the post to it's previous status.

Previous statuses were added in version 0.4.0, if the content was archived prior to that version of the plugin then the previous status is not set and the content will be unarchived into draftstatus.

You can be change the this behavior with the aps_unarchive_post_status filter.

From the Posts screen

The Posts screen displays content in a table format, with each post as a row in the table.

From this screen a user can modify each entry with Row Actions, the "Quick Edit" interface, or with Bulk Actions. See more about these actions here.

Example: Edit Posts admin screen

Archived Post Status provides options in the posts screen for core content types post and page, as well as all public custom post types. See Extending the Plugin for how to modify this behavior.

Unarchive with Inline Action

When a user mouses over or focuses on an entry in the table, a list of links displays "inline" actions. Archived entries will have an link to "Unarchive" the content.

  1. From the Edit Screen, navigate to the "Archived" filter

  2. Hover over the row for the content

  3. Click on the "Unarchive" link

Unarchiving content with inline action

Bulk Unarchive

To unarchive content in bulk:

  1. Navigate to the "Archived" content in the edit screen.

  2. Select the archived entries to be unarchived.

  3. From the "Bulk actions" dropdown, select "Unarchive."

  4. Click "Apply"

Unarchive content in bulk

Note on Quick Edit

Prior to version 0.4.0 this plugin supported changing the post status in the "Quick Edit" via the status dropdown.

In version 0.4.0 this functionality was replaced with the inline and bulk actions above, to better align with how WordPress core handles post-published statuses like Trash.

With a Function

Content can be removed from the archive, "unarchived," in a plugin or theme using the aps_unarchive_post function:

This is modeled after the WordPress core behavior for untrashing posts, however the new post status will default to the previous status with the unarchive function.

Parameters

$post_id int optional

Post ID. Default is the ID of the global $post

Return

WP_Post | false Post data on success, false on failure.

Example

With WP CLI

As of version 0.4.0, CLI commands similar to wp post delete (source) are available to archive content.

Options

<id>...

One or more IDs of posts to archive

[--status]

Override the new status of the post(s).

[--defer-term-counting]

Recalculate term count in batch, for a performance boost.

Examples

Note: Unarchiving more than 20 posts with the CLI command will output a progress bar instead of a success message:

Unarchiving content without the plugin

If you deactivate/uninstall the Archived Post Status plugin the archive status will no longer exist.

This means any archived content will become inaccessible. The entries will still exist in the database, but they will no longer be recognized by WordPress as valid content to display.

It's best to reinstall & reactivate Archived Post Status, unarchive via the methods above, and then proceed to remove the plugin.

However, if you've removed the plugin or cannot use it, here are some ways to update the status of your archived content without the plugin.

With WP-CLI

Here's a single command that retrieves all posts with a post status of "archive" across all public post types and then changes their status to draft:

Explanation:

  • wp post-type list --field=name --format=csv | grep -E "1$" | tr '\n' ',' | sed 's/,$//': This part of the command retrieves the names of all public post types by filtering the output of wp post-type list to include only post types where the 'public' field is set to 1. It then formats the output as comma-separated values (CSV).

  • wp post list --post_type=... --post_status=archive --field=ID: This command lists all posts with post status "archive" and post types obtained from the previous command. It retrieves only the IDs of these posts.

  • wp post update ... --post_status=draft: This part of the command updates the status of the retrieved posts to "draft". Change "draft" to another status as needed.

This command will effectively change the post status to "draft" for all posts with the "archive" status across all public post types.

Note: There are limits to the number of arguments you can pass to the wp post update command, so if you have a lot of archived content this command might not work.

Last updated