Custom Post Status not showing in Custom Post Type ALL view

I’ve created a simple plugin for our WP site to allow us to enter in our products that we despatch.

To do this I’ve created a new Post Type called ‘order_packing’ and within that 2 new Post Statuses: ‘In Packing’, ‘Sent’.

The problem I have is that list correctly shows the packing lists within the ALL (2) total – but doesn’t list the packing lists. If I click the ‘Sent’ status then I get both shown in the list. So my issue is the data is there, but they’re not showing under the ALL tab.

Here’s the code that creates the Post Type, this all works perfectly

enter code here    register_post_type( 'order_packing',
    array(
        'labels'              => array(
        'name'                  => __( 'Order Packing', 'tgplugin' ),
        'singular_name'         => _x( 'Order Packing', 'order_packing post type singular name', 'tgplugin' ),
        'add_new'               => __( 'Add Packing List', 'tgplugin' ),
        'add_new_item'          => __( 'Add Packing List', 'tgplugin' ),
        'edit'                  => __( 'Edit', 'tgplugin' ),
        'edit_item'             => __( 'Edit Packing List', 'tgplugin' ),
        'new_item'              => __( 'New Packing List', 'tgplugin' ),
        'view'                  => __( 'View Packing List', 'tgplugin' ),
        'view_item'             => __( 'View Packing List', 'tgplugin' ),
        'search_items'          => __( 'Search Packing Lists', 'tgplugin' ),
        'not_found'             => __( 'No Packing Lists found', 'tgplugin' ),
        'not_found_in_trash'    => __( 'No Packing Lists found in trash', 'tgplugin' ),
        'parent'                => __( 'Parent Packing List', 'tgplugin' ),
        'menu_name'             => _x( 'Stock Packing List', 'Admin menu name', 'tgplugin' ),
        'filter_items_list'     => __( 'Filter Packing Lists', 'tgplugin' ),
        'items_list_navigation' => __( 'Packing List navigation', 'tgplugin' ),
        'items_list'            => __( 'Packing Lists', 'tgplugin' ),
    ),
        'description'         => __( 'This is where Packing Lists are stored.', 'tgplugin' ),
        'public'              => false,
        'show_ui'             => true,
        'capability_type'     => 'packing_list',
        'map_meta_cap'        => true,
        'publicly_queryable'  => false,
        'exclude_from_search' => true,
        'show_in_menu'        => true,
        'hierarchical'        => false,
        'show_in_nav_menus'   => false,
        'menu_position'       => 100,
        'rewrite'             => false,
        'query_var'           => false,
        'supports'            => array( 'title', 'comments', 'custom-fields' ),
        'has_archive'         => false,
    )
);

Here are the Custom Statuses for that Custom Post Type.

 register_post_status( 'inpacking', array(
    'label'                     => _x( 'In Packing', 'Order packing' ),
    'public'                    => false,
    'exclude_from_search'       => false,
    'show_in_admin_all_list'    => true,
    'show_in_admin_status_list' => true,
    'label_count'               => _n_noop( 'In Packing <span class="count">(%s)</span>', 'In Packing <span class="count">(%s)</span>' ),
 ) );

 register_post_status( 'sent', array(
    'label'                     => _x( 'Sent', 'Order packing' ),
    'public'                    => false,
    'exclude_from_search'       => false,
    'show_in_admin_all_list'    => true,
    'show_in_admin_status_list' => true,
    'label_count'               => _n_noop( 'Sent <span class="count">(%s)</span>', 'Sent <span class="count">(%s)</span>' ),
 ) );

Finally here are two images showing the issue.

All showing correct total but no posts
Posts shown correctly when Sent is clicked

I’m scratching my head and have searched and searched, I did find this post but there’s no answers to it.

https://stackoverflow.com/questions/29434046/wordpress-posts-with-custom-status-need-to-show-in-all-view

I hope someone can help save my sanity!

Cheers
Colin

2 Answers
2

You should set the public argument to true. This way the post with ‘inpacking’ or ‘sent’ post_status will also show in total.

So your code should be like this:

register_post_status( 'inpacking', array(
    'label'                     => _x( 'In Packing', 'Order packing' ),
    'public'                    => true,
    'exclude_from_search'       => false,
    'show_in_admin_all_list'    => true,
    'show_in_admin_status_list' => true,
    'label_count'               => _n_noop( 'In Packing <span class="count">(%s)</span>', 'In Packing <span class="count">(%s)</span>' ),
 ) );

register_post_status( 'sent', array(
    'label'                     => _x( 'Sent', 'Order packing' ),
    'public'                    => true,
    'exclude_from_search'       => false,
    'show_in_admin_all_list'    => true,
    'show_in_admin_status_list' => true,
    'label_count'               => _n_noop( 'Sent <span class="count">(%s)</span>', 'Sent <span class="count">(%s)</span>' ),
) );

Leave a Comment