Modify Post Status Arguments

Is it possible to edit existing registered post statuses?

I am using the Edit Flow plugin to create custom statuses, however, the plugin does not offer the option to set whether the statuses are ‘public’ or not. I went in to the code and was able to insert that in, but obviously that will get overwritten with any updates. Essentially, I am looking for a complimentary function to add_post_type_support() for post statuses.

Read More

So something like

add_action('init', 'my_custom_init');
function my_custom_init() {

      add_post_status_support( 'custom_status', array('public'=>true) );

}

Related posts

Leave a Reply

1 comment

  1. You can alter a post status after init by changing the global variable $wp_post_statusses:

    function alt_post_status() {
        global $wp_post_statuses;
    
        $wp_post_statuses['custom_status']->public = true;
    }
    
    add_action( 'init', 'alt_post_status' );
    

    register_post_status() (line 922) does the same thing:

    ...
    
    global $wp_post_statuses;
    
    if (!is_array($wp_post_statuses))
        $wp_post_statuses = array();
    
    // Args prefixed with an underscore are reserved for internal use.
    $defaults = array(
        'label' => false,
        'label_count' => false,
        'exclude_from_search' => null,
        '_builtin' => false,
        'public' => null,
        'internal' => null,
        'protected' => null,
        'private' => null,
        'publicly_queryable' => null,
        'show_in_admin_status_list' => null,
        'show_in_admin_all_list' => null,
    );
    $args = wp_parse_args($args, $defaults);
    $args = (object) $args;
    
    ...
    
    $wp_post_statuses[$post_status] = $args;
    
    ...