Skip to main content

Unpublish Feature

Summary

The Unpublish Feature switches a post to draft at a date and time an editor chooses. It works in the block editor and the classic editor, and in both the field lives with the post's other publishing controls.

SurfaceBlock editorClassic editor
Where the field isSummary panel, under the publish date (PluginPostStatusInfo)Publish metabox (post_submitbox_misc_actions)
ControlDateTimePicker in a dropdown, opened from the current valueACF date_time_picker
Saved byPost meta over the REST APIThe post form, on save_post
Past date rejectedInline warning in the panel; the picker greys out past daysAdmin warning notice after the save
ACF "Scheduled Unpublishing" metaboxHidden — the Summary panel is the one controlShown below the content, as ACF renders any field group

Both editors store the same unpublish_date post meta, in GMT, and both schedule the same Action Scheduler action. Nothing else about the feature changes with the editor.

What it adds

  • Settings > Writing. A "Yoko's Scheduled Unpublishing Settings" section for choosing which post types offer the field. Nothing appears on a post type that is not selected.
  • A per-post Unpublish Date field. Set in the site's timezone, stored in GMT, and shown back in the site's timezone. Daylight saving is resolved for the chosen date, not for today.
  • A scheduled action. Yoko\UnpublishPost runs at the stored time and sets the post to draft, retrying up to three times five minutes apart.

Requirements

  • ACF – Advanced Custom Fields
  • Action Scheduler
warning

The whole feature — the settings section included — is gated on ACF. Without it there is nothing to configure and no field in either editor.

Rules

SituationWhat happens
Date in the futureStored, and the action is scheduled.
Date in the pastRefused. The previously stored date and its pending action are both left alone.
Date clearedStored as empty, and the pending action is cancelled.
Post edited without touching the dateNothing is rescheduled, and a date that has already passed is not re-validated.
Post unpublished by the actionThe date stays on the post, as a record of when it came down.

Testing Guide

  1. Select CPTs. Under Settings > Writing, select the post types to enable.

  2. Block editor. Open a published post of one of those types.

    • The Unpublish Date row is in the Summary panel, showing Never.
    • Choose a future date and time, then update the post. Reload: the same local time is shown.
    • Confirm the stored value is GMT: wp post meta get <post_id> unpublish_date.
    • Choose a past date. The picker greys out past days, and a past time today raises the inline warning without changing the stored value.
    • Press Clear, then update. The meta empties and the pending action disappears from Tools > Scheduled Actions.
  3. Classic editor. Repeat on a post type the Classic Editor plugin has taken over.

    • The Unpublish Date field is in the Publish metabox.
    • A past date produces the admin warning notice: "The unpublish date was not updated because you cannot schedule unpublishing on a past date."
  4. Run the action. Go to Tools > Scheduled Actions, filter by Pending, find Yoko\UnpublishPost and click Run. The post becomes a draft.

  5. Check the timezone. Set Settings > General to a timezone several hours from your browser's, then repeat step 2. The time shown must match what you entered, not your browser's clock.

Additional Notes and Troubleshooting

SymptomCause
No field in the Summary panelThe post type is not selected under Settings > Writing, or build/yoko-unpublish-date.js is missing — run npm run build.
The field takes a date and loses it on saveThe post type's REST schema has no meta object. Check wp eval 'var_dump( post_type_supports( "your_cpt", "custom-fields" ) );'.
The date saves but the post never unpublishesCheck the pending action at wp-admin/tools.php?page=action-scheduler and the log below.
The time is out by an hourConfirm the site timezone under Settings > General is a named zone rather than a fixed UTC offset — a fixed offset cannot follow daylight saving.
The calendar highlights the day before the one in the date fieldsYour computer's timezone differs from the site's. Core's date picker labels its calendar from the site's zone but decides the highlight from your computer's, and its own Publish picker does the same. The stored value is unaffected.
  • The date is stored in GMT and converted to local time for display. Confirm the site timezone under Settings > General is correct.
  • Scheduled unpublishing is logged with yoko_log to yoko-logs/yoko-unpublish-post-yyyy-mm-dd.log.
  • The unpublish date is only readable over the REST API by users who can edit posts. It was never on the API before the block editor panel existed, and adding the panel did not change that.

Screenshots

Unless noted, captured against a site set to America/New_York with the value stored as 2026-09-30 21:00:00 GMT — so every shot below is the same instant, converted for display.

Settings

Settings &gt; Writing

Settings > Writing. Nothing appears on a post type that is not listed here.

Settings &gt; Writing, in place

The same setting in its section on a live site.

Block editor

Summary panel

The field sits in the Summary panel with the post's other publishing controls, and wraps onto a second line the same way the Publish row above it does.

Date picker

The picker, opened from the current value. Past days are greyed out, Clear removes the date, and the note names the timezone every time on screen is in.

Past date warning

A time earlier today — the one past value the calendar cannot grey out. The warning is the classic editor's, shown inline rather than after a reload, and the date is not written.

Classic editor

Classic Publish metabox

Same post, same stored GMT value: the Publish metabox shows the identical local time.

Classic date picker

The classic control is ACF's jQuery calendar, not the block editor's. Different widget, same week start and same value.

Classic editor on a live site

The original capture, on a live site in the America/Sao_Paulo timezone. The helper text names whichever timezone the site is set to.

Both editors

Pending scheduled action

Tools > Scheduled Actions. One Yoko\UnpublishPost per post, carrying the post ID and the attempt counter, due at the stored GMT instant — whichever editor set it.