admin管理员组文章数量:1202815
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.
I'm scratching my head and have searched and searched, I did find this post but there's no answers to it.
I hope someone can help save my sanity!
Cheers Colin
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.
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
Share Improve this question edited Jun 15, 2020 at 8:21 CommunityBot 1 asked Feb 11, 2017 at 18:56 Colin RichardsonColin Richardson 311 silver badge2 bronze badges2 Answers
Reset to default 2You 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>' ),
) );
Old question/answer, but clarification to the question should be addressed.
First, the codex identifies the default values of both show_in_admin_all_list
and show_in_admin_status_list
to have a default value that is opposite of internal
and the exclude_from_search
as the same of internal
. The doc indicates the default setting is internal=FALSE
so you don't have to explicitly set it or anything related to it.
Second, though @pck is correct in that setting public=TRUE
will solve the problem, there is an issue with this answer. Not only will setting public=TRUE
give access to posts having this status on the front end (both in display and query), but permission issues could occur as well. Such an outcome is not acceptable in many cases, like when internal company shipping processes are not to be made available to the public or users lacking proper credentials. (I assume this is your situation as you have public=FALSE
and capability_type
set in your registration of the order_packing
post type.) What @pck is eluding to is that the public
, protected
, or private
argument needs to be set in order for the posts of the custom status to be displayed in the "All" view. This is because the code of WP_Query->get_posts()
will only return posts having statuses registered with one of these arguments set.
With these two things in mind, a more appropriate solution to your specific circumstance would be:
register_post_status( 'inpacking', array(
'label' => _x( 'In Packing', 'Order packing' ),
'private' => 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' ),
'private' => true,
'label_count' => _n_noop( 'Sent <span class="count">(%s)</span>', 'Sent <span class="count">(%s)</span>' ),
) );
本文标签: Custom Post Status not showing in Custom Post Type ALL view
版权声明:本文标题:Custom Post Status not showing in Custom Post Type ALL view 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738657841a2105243.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论