Make WordPress Core

Opened 9 years ago

Closed 8 months ago

#42089 closed enhancement (maybelater)

Function to detect if current page is a preview of a draft

Reported by: paulschreiber's profile paulschreiber Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

It would be very helpful if there was a function to detect if the page being viewed is a preview of a draft. Call this is_draft_preview().
Currently, you can achieve this check with code like this:

<?php
function is_draft_preview() {
    global $post;
    $is_draft = 'draft' === $post->post_status;
    return ( is_preview() && $is_draft );
}

Change History (3)

#1 @SergeyBiryukov
8 years ago

  • Component changed from General to Posts, Post Types
  • Description modified (diff)

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


8 months ago

#3 @SirLouen
8 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed
  • Version 4.8.2 deleted

This seems to be pretty much the same as #42088 and the same answer but using draft for the $post_status.

Same conclusion, time to close it as maybelater, but again I doubt this should ever be added.

Note: See TracTickets for help on using tickets.