WordPress.org

Make WordPress Core

Opened 9 months ago

Last modified 4 months ago

#42089 new enhancement

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

Reported by: paulschreiber Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.8.2
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 (1)

#1 @SergeyBiryukov
4 months ago

  • Component changed from General to Posts, Post Types
  • Description modified (diff)
Note: See TracTickets for help on using tickets.