5

I'm trying to create two custom post status'. I used the Codex to generate the code and that didn't work. Then I went to http://generatewp.com/post-status and it didn't work either. It isn't showing up in the dropdown next to "Status" in "Edit Post".

Do you see anything wrong with my code?

// ***** http://generatewp.com/post-status **** //

function custom_post_status() {

$args = array(
'label' => 'Reserve',
'label_count' => 'Reserve (%s)',
'public' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'exclude_from_search' => false,
);
register_post_status( 'Reserve', $args );

}

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

function custom_post_status_2() {

$args = array(
'label' => 'Ready to be Scheduled',
'label_count' => 'Ready to be Scheduled (%s)',
'public' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'exclude_from_search' => false,
);
register_post_status( 'Ready to be Scheduled', $args );

}

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

Thank you!

6

The post status values seems to be hardcoded in the core. Here's the status box code for the edit screen:

<span id="post-status-display">
<?php
switch ( $post->post_status ) {
        case 'private':
                _e('Privately Published');
                break;
        case 'publish':
                _e('Published');
                break;
        case 'future':
                _e('Scheduled');
                break;
        case 'pending':
                _e('Pending Review');
                break;
        case 'draft':
        case 'auto-draft':
                _e('Draft');
                break;
}
?>
</span>

The Codex says:

NOTICE: This function does NOT add the registered post status to the admin panel. This functionality is pending future development. Please refer to Trac Ticket #12706. Consider the action hook post_submitbox_misc_actions for adding this parameter.

The #12706 ticket was created 5 years ago!

So I don't think this is currently supported by the core.

If you manually change the status of a post, to a registered custom post status, then you will see it among the tabs on the edit.php screen.

Testing on WP 4.1:

When I try out the Codex example:

function my_custom_post_status(){
        register_post_status( 'unread', array(
                'label'                     => _x( 'Unread', 'post' ),
                'public'                    => true,
                'exclude_from_search'       => false,
                'show_in_admin_all_list'    => true,
                'show_in_admin_status_list' => true,
                'label_count'               => _n_noop( 'Unread <span class="count">(%s)</span>', 'Unread <span class="count">(%s)</span>' ),
        ) );
}
add_action( 'init', 'my_custom_post_status' );

and manually modify the post status of a post to unread, then the status for that post is not showing in the meta-box:

Missing status

On the other hand it shows in tabs on the edit.php screen:

Shows in the edit.php tabs

| improve this answer | |
  • I wonder what the point of even creating new status' if they don't appear in the admin panel? Thanks for your response. For another blog, I use this plugin and it works pretty well: editflow.org – Tara Feb 1 '15 at 17:30
  • 1
    It looks like it's still on the drawing board. I guess the plugin is using some javascript to adjust the status box, but I haven't checked. – birgire Feb 1 '15 at 17:35
0

I'd change the priority on add_action to 1 and see if that fixes things.

To the best of my knowledge, priority must be an integer between 1 and 99 inclusive.

Use 0 or 100+ and I don't believe that your action will ever fire.

I'd also recommend changing the names of your registered statuses to match those that exist (e.g. all lowercase with no spaces and probably short) You can check the post_status column of the wp_posts table to see what limits there are on them, but try:

register_post_status( 'reserve', $args );

register_post_status( 'ready', $args );

Your labels will make them look decent.

| improve this answer | |
  • Changed the first one to 20 and the second to 30 and it didn't work. :( – Tara Feb 1 '15 at 17:12
  • Try changing the names as per my updated response. – Privateer Feb 1 '15 at 17:16
  • Unfortunately, that didn't work either. – Tara Feb 1 '15 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.