未显示自定义帖子状态 [英] Custom post status not appearing

查看:32
本文介绍了未显示自定义帖子状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的一个客户构建一个目录主题,我喜欢通过将帖子状态从发布更改为已过期来在帖子中添加过期功能.

I am building a directory theme for a client of mine, and I like to add the feature of expiration in the posts by modifying the post status from publish to expired.

为此,我尝试使用以下代码注册新的帖子状态:

To achieve that, I am trying to register a new post status by using the following code:

add_action('init',    'registerStatus', 0);

function registerStatus()
{
    $args = array(
        'label'                     =>  _x('Expired', 'Status General Name', 'z' ),
        'label_count'               =>  _n_noop('Expired (%s)',  'Expired (%s)', 'z'),
        'public'                    =>  true,
        'show_in_admin_all_list'    =>  true,
        'show_in_admin_status_list' =>  true,
        'exclude_from_search'       =>  true
    );

    register_post_status('expired', $args);
}

问题是,无论是在 WordPress 帖子中,还是在我的自定义帖子类型帖子状态中,我都看不到已注册的帖子状态.

The problem is that I cannot see the registered post status either in WordPress posts, either in my custom post type post statuses.

我做错了什么吗?

推荐答案

自定义帖子状态功能仍在开发中(就像过去四年一样!),请参阅 https://core.trac.wordpress.org/ticket/12706,以及对 https://wordpress.stackexchange.com/q/67655/25765.更多有用信息:https://wordpress.stackexchange.com/search?q=register_post_status.

Custom post status functionality is still under development (as it has been for the past four years!), see https://core.trac.wordpress.org/ticket/12706, and comments on https://wordpress.stackexchange.com/q/67655/25765. More useful info here: https://wordpress.stackexchange.com/search?q=register_post_status.

就我个人而言,我强烈不鼓励实现自定义帖子状态,但如果真的有必要,您可以查看 编辑流程 插件处理它.

Personally, I'd strongly discourage implementing custom post statuses, but if really necessary, you could take a look at how the Edit Flow plugin handles it.

这篇关于未显示自定义帖子状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆