get_post_status()获取文章的状态

目录

描述

译文

按文章ID检索文章状态。

如果文章ID是附件,该函数给出源文章的状态。

原文

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.

get_post_status() 描述

用法

<?php get_post_status$ID ?>

get_post_status() 用法

参数

$ID

(integer) (可选) Post ID. This function will will return the status of the current post if $ID is not provided.

默认值: ''

get_post_status() 参数

返回值

(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.

get_post_status() 返回值

示例

A basic example:

get_post_status() 示例

历史

  • 添加于 版本: 2.0.0

get_post_status() 历史

源文件

get_post_status() 函数的代码位于 wp-includes/post.php.

get_post_status() 源文件