Languages:
English •
Italiano •
post status 日本語
Русский •
(Add your language)
Description
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.
Usage
<?php get_post_status( $ID ) ?>
Parameters
- $post
- (int/object) (optional) Post ID or post object. This function will will return the status of the current post if $ID is not provided.
- Default: ''
Return Values
- (string|boolean)
- Post status or false on failure.
Possible values are:
- 'publish' - A published post or page
- 'pending' - post is pending review
- 'draft' - a post in draft status
- 'auto-draft' - a newly created post, with no content
- 'future' - a post to publish in the future
- 'private' - not visible to users who are not logged in
- 'inherit' - a revision. see get_children.
- 'trash' - post is in trashbin. added with Version 2.9.
Examples
A basic example:
<?php
if ( get_post_status ( $ID ) == 'private' ) {
echo 'private';
} else {
echo 'public';
}
?>
Notes
Change Log
Source File
get_post_status() is located in wp-includes/post.php
.
Related