您想在 WordPress 中为您的博客文章添加自定义帖子状态吗?帖子状态是一种编辑工具,可让您根据编辑工作流程中的各自阶段来组织文章。在本文中,我们将向您展示如何轻松地将自定义帖子状态添加到 WordPress 中的博客帖子中。
您想在 WordPress 中向您的博客文章添加自定义帖子状态吗?发布状态是一种编辑工具,可让您根据文章在编辑工作流程中的阶段来组织文章。在本文中,我们将向您展示如何轻松地将自定义帖子状态添加到 WordPress 中的博客帖子中。

WordPress中的职位状态是什么?为什么需要它? (What is Post Status in WordPress and Why Do You Need it?)
帖子状态 is an editorial tool that tells WordPress the stage of a blog post during editing. For example, posts that are incomplete are saved with the post status labeled ‘Draft’. When you publish an article, the status changes to ‘Published’.
帖子状态是一种编辑工具,可告诉WordPress编辑期间博客帖子的阶段。 例如,不完整的帖子将以帖子状态标记为“草稿”保存。 发布文章时,状态更改为“已发布”。

帖子状态可帮助 WordPress 选择如何在您的网站上处理和显示博客帖子。例如,它会自动从您的主页和网站的其他公开可见区域中排除标记为草稿的帖子。
发布状态可帮助 WordPress 选择如何在您的网站上处理和显示博客文章。例如,它会自动从您的主页和网站的其他公开可见区域中排除标记为草稿的帖子。
默认情况下,WordPress 附带您可以使用的以下帖子状态:
默认情况下,WordPress 有以下可用的帖子状态:
- Draft – An item that is saved but incomplete and not yet published 草稿–已保存但不完整且尚未发布的项目
- 修订.修订版 。
- Pending review – Items that are complete and submitted for review but not yet published. 待审核–已完成但已提交但尚未发布的项目。
- 已安排的帖子 to be published later.发布时间表以后发布。
- Private – Items marked as private 私人-标为私人的项目
- Trash – Items that are trashed 垃圾箱–垃圾箱
- Inherit – Child pages that automatically inherit status of their parent page. 继承–子页面自动继承其父页面的状态。
除了这些默认帖子状态之外,您还可以创建自己的自定义帖子状态以改进您的编辑工作流程。例如,您可以为完整但不适合发布的帖子添加“不适合”标签。
除了这些默认帖子状态之外,您还可以创建自己的自定义帖子状态以改进编辑工作流程。例如,您可以将标签“不适合”添加到已完成但不适合发布的帖子。
话虽如此,让我们来看看如何在 WordPress 中轻松创建自定义帖子状态。
话虽如此,让我们看看如何在 WordPress 中轻松创建自定义帖子状态。
方法1.使用插件创建自定义帖子状态 (Method 1. Create Custom Post Status Using a Plugin)
This method is easier and recommended for most users. It allows you to create custom post statuses as well as 有效管理编辑工作流程 on your multi-author WordPress blog.
此方法更简单,建议大多数用户使用。 它使您可以创建自定义帖子状态,并有效的管理多作者WordPress博客上的编辑工作流程 。
The first thing you need to do is install and activate the 编辑流程 plugin. For more details, see our step by step guide on 如何安装 WordPress 插件.
您需要做的第一件事是安装并激活编辑流程插件。 有关更多详细信息,请参阅有关如何安装 WordPress 插件步指南。
激活后,该插件将在您的 WordPress 管理菜单中添加一个标有“编辑流程”的新菜单项。单击它将带您进入插件的设置页面。
激活后,该插件将向您的 WordPress 管理菜单添加一个名为“编辑流程”的新菜单项。单击它将带您进入插件的设置页面。

编辑流程附带许多有用的功能,您可以从此屏幕打开/关闭它们。继续并单击“自定义状态”框下的“编辑状态”按钮继续。
编辑流程有许多有用的功能,您可以从此屏幕打开/关闭。继续并单击“自定义状态”框下方的“编辑状态”按钮继续。
编辑流程自动创建以下自定义帖子状态:
编辑过程会自动创建以下自定义帖子状态:
- Pitch – Used to pitch new article ideas and this status also becomes the default post status of every new post. 推销–用于推销新文章的想法,此状态也成为每个新帖子的默认帖子状态。
- Assigned – You can select an author and mark an article as assigned so that the author can work on it. 已分配–您可以选择作者并将文章标记为已分配,以便作者可以对其进行处理。
- In progress – Writer is working on the post but is not yet available as a readable draft. 进行中– Writer正在撰写帖子,但尚不可读。

您可以通过在左栏中提供名称和描述来创建自己的自定义状态。完成后,单击“添加新状态”按钮保存更改。
您可以通过在左栏中提供名称和描述来创建自己的自定义状态。完成后,单击“添加新状态”按钮保存更改。
您的自定义状态现在将显示在右侧栏中,以便您可以随时编辑或删除它。
您的自定义状态现在将显示在右栏中,以便您可以随时编辑或删除它。

Next, you need to go to 帖子 » 添加新帖子 page to create a new post. On the post edit screen, click on the ‘Edit’ link next to status option under the ‘Publish’ meta box.
接下来,您需要转到帖子 » 添加新帖子页面以创建新帖子。 在帖子编辑屏幕上,单击“发布”元框下状态选项旁边的“编辑”链接。

这将显示一个下拉菜单,显示您可以选择的所有帖子状态,包括您刚刚创建的自定义帖子状态。
这将显示一个下拉菜单,显示您可以选择的所有帖子状态,包括您刚刚创建的自定义帖子状态。
You can also see all articles filed under different post statuses by visiting 帖子 » 所有帖子 page.
您还可以通过访问帖子 » 所有帖子页面查看以不同帖子状态归档的所有文章 。

方法2。使用代码创建自定义帖子状态 (Method 2. Create Custom Post Status Using Code)
WordPress has a known 漏洞 in the API used to register custom post statuses. It allows you to create custom post status, but you cannot use it in the admin panel. This means that the coding method can get the job done, but it is not as clean, and you will need to change it after it is officially fixed.
WordPress在用于注册自定义帖子状态的API中存在一个已知的错误 。 它允许您创建自定义帖子状态,但是不能在管理面板中使用它。 这意味着编码方法可以完成工作,但是还不够干净,在正式修复后,您需要对其进行更改。
但是,如果您仍然想手动执行此操作,那么您可以继续阅读。
但是,如果您仍然想手动执行此操作,可以继续阅读。
This method requires you to add code to your WordPress site. If you haven’t done this before, then take a look at our guide on 如何在 WordPress 中复制和粘贴代码.
此方法要求您将代码添加到WordPress网站。 如果您以前没有做过,请查看我们的指南, 了解如何在 WordPress 中复制和粘贴代码 。
First, you need to add the following code to your theme’s 函数.php file or a 特定于站点的插件.
首先,您需要将以下代码添加到主题的函数.php文件或具体的于在网站的插件中 。
// Registering custom post status
function wpb_custom_post_status(){
register_post_status('rejected', array(
'label' => _x( 'Rejected', 'post' ),
'public' => false,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Rejected <span class="count">(%s)</span>', 'Rejected <span class="count">(%s)</span>' ),
) );
}
add_action( 'init', 'wpb_custom_post_status' );
// Using jQuery to add it to post status dropdown
add_action('admin_footer-post.php', 'wpb_append_post_status_list');
function wpb_append_post_status_list(){
global $post;
$complete = '';
$label = '';
if($post->post_type == 'post'){
if($post->post_status == 'rejected'){
$complete = ' selected="selected"';
$label = '<span id="post-status-display"> Rejected</span>';
}
echo '
<script>
jQuery(document).ready(function($){
$("select#post_status").append("<option value=\"rejected\" '.$complete.'>Rejected</option>");
$(".misc-pub-section label").append("'.$label.'");
});
</script>
';
}
}
不要忘记将“rejected”一词的所有实例替换为您自己的自定义帖子状态。
不要忘记将被拒绝单词的所有实例替换为您自己的自定义帖子状态。
此代码注册自定义帖子状态,然后使用 jQuery 将其添加到管理面板。您现在可以编辑 WordPress 帖子,并且可以在状态下拉菜单中看到它。
此代码注册自定义帖子状态,然后使用 jQuery 将其添加到管理面板。现在您可以编辑您的 WordPress 帖子,并且可以在状态下拉菜单中看到它。

We hope this article helped you add custom post status to blog posts in WordPress. You may also want to see our list of 超过 55 个最受欢迎的 WordPress 提示、技巧和窍门.
我们希望本文能帮助您将自定义帖子状态添加到WordPress中的博客帖子中。 您可能还希望查看我们的超过 55 个最受欢迎的 WordPress 提示、技巧和技巧的列表 。
If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-custom-post-status-for-blog-posts-in-wordpress/