Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_post_status [ WordPress Function ]

get_post_status ( $ID = '' )
Parameters:
  • (int) $ID Post ID
Returns:
  • (string|bool) Post status or false on failure.
Defined at:



Retrieve the post status based on the Post ID.

If the post ID is of an attachment, then the parent post status will be given instead.

Source


<?php
function get_post_status($ID '') {
    
$post get_post($ID);

    if ( !
is_object($post) )
        return 
false;

    if ( 
'attachment' == $post->post_type ) {
        if ( 
'private' == $post->post_status )
            return 
'private';

        
// Unattached attachments are assumed to be published
        
if ( ( 'inherit' == $post->post_status ) && ( == $post->post_parent) )
            return 
'publish';

        
// Inherit status from the parent
        
if ( $post->post_parent && ( $post->ID != $post->post_parent ) )
            return 
get_post_status($post->post_parent);
    }

    return 
$post->post_status;
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

User discussions [ wordpress.org ]

0 User Note(s)

None yet. Be the first!

Add New ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics