Custom Post Type Statuses

I’m (still) working on a custom post type plugin for my workplace and came across an easier method of marking Visitors (my custom post type) as either “Here” (aka checked-in) or “Not Here” (not checked-in).

I’ve explored the Edit Flow plugin and, to be honest, I can’t really follow what all is going on here… I did however come across a function that appears to be in WordPress’ core, but I can’t seem to find much documentation on the web (none on wordpress.org even). The function is register_post_status but the best I found was this resource which at best only shows me the arguments that go with the function’s $args parameter.

Anyone ever tried this? Or am I the only one who’s really needed custom post statuses for custom post types?

EDIT: I’ve read this and this as per the answers/comments I’ve received. Here is an implementation that I’m not 100% sure about because documentation is lacking.

I know it doesn’t work, but I don’t get why it doesn’t work. Neither of the two statuses show up in the status list. My next course of action is to hack it with a taxonomy and just create my own ‘Publish’ meta box.

    register_post_status('in', array(
            'label' => _x( 'Logged In', $post_type ),
            'protected' => true,
            'label_count' => _n_noop( 'Visitors logged in <span class="count">(%s)</span>', 'Visitors logged in <span class="count">(%s)</span>' ),
            'show_in_admin_status_list' => true,
        ));

    register_post_status('out', array(
            'label' => _x( 'Logged Out', $post_type ),
            'protected' => true,
            'label_count' => _n_noop( 'Visitors logged out <span class="count">(%s)</span>', 'Visitors logged out <span class="count">(%s)</span>' ),
            'show_in_admin_status_list' => true,
        ));

2 Answers
2

Custom post statuses do exist in the core code of WordPress, so you can register them, but they are not yet properly implemented in the admin screens (e.g. they don’t show in the dropdown list of statuses alongside Pending Review, Draft, Published). So essentially you can do very little with them at the moment.

You can read more on Trac ticket 12706.

Leave a Comment