[wp-trac] [WordPress Trac] #42089: Function to detect if current page is a preview of a draft

WordPress Trac noreply at wordpress.org
Sat Feb 24 11:52:10 UTC 2018


#42089: Function to detect if current page is a preview of a draft
-------------------------------+------------------------------
 Reporter:  paulschreiber      |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  4.8.2
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------
Changes (by SergeyBiryukov):

 * component:  General => Posts, Post Types


Old description:

> It would be very helpful if there was a function to detect if the page
> being viewed is a scheduled post. Call this is_draft_preview().
> Currently, you can achieve this check with code like this:
> {{{#!php
> <?php
> function is_draft_preview() {
>     global $post;
>     $is_draft = 'draft' === $post->post_status;
>     return ( is_preview() && $is_draft );
> }
> }}}

New description:

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

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42089#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list