最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - Custom product status get filtered on all product list views

programmeradmin1浏览0评论

I registred a new product status with this code :

function register_custom_post_status(){
        register_post_status( 'invalid', array(
            'label'                     => __( 'Not valid', 'xx' ),
            'label_count'               => _n_noop( 'not valid <span class="count">(%s)</span>', 'Not valid <span class="count">(%s)</span>'),
            'public'                    => false,
            'exclude_from_search'       => true,
            'show_in_admin_all_list'    => true,
            'show_in_admin_status_list' => true
        ));
    }

When I set a product on this status ( $product->set_status(‘invalid’); ) the all products list table filter out my product and shows it only in his separate table list. But ‘show_in_admin_all_list’ is set to true, so why happen this? I’m confused.

I registred a new product status with this code :

function register_custom_post_status(){
        register_post_status( 'invalid', array(
            'label'                     => __( 'Not valid', 'xx' ),
            'label_count'               => _n_noop( 'not valid <span class="count">(%s)</span>', 'Not valid <span class="count">(%s)</span>'),
            'public'                    => false,
            'exclude_from_search'       => true,
            'show_in_admin_all_list'    => true,
            'show_in_admin_status_list' => true
        ));
    }

When I set a product on this status ( $product->set_status(‘invalid’); ) the all products list table filter out my product and shows it only in his separate table list. But ‘show_in_admin_all_list’ is set to true, so why happen this? I’m confused.

Share Improve this question asked Jan 22, 2020 at 8:42 ToninoTonino 1
Add a comment  | 

1 Answer 1

Reset to default 0

I think Below code will slove your problem.I have tested it. /** * Add 'Unread' post status. */ function wpdocs_custom_post_status(){ register_post_status( 'unread', array( 'label' => _x( 'Unread', 'post' ), 'label_count' => _n_noop( 'Unread (%s)', 'Unread (%s)'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true )); } add_action( 'init', 'wpdocs_custom_post_status' ); function my_custom_status_add_in_quick_edit() { echo " jQuery(document).ready( function() { jQuery( 'select[name=\"_status\"]' ).append( 'Unread' );
}); "; } add_action('admin_footer-edit.php','my_custom_status_add_in_quick_edit'); function my_custom_status_add_in_post_page() { echo " jQuery(document).ready( function() {
jQuery( 'select[name=\"post_status\"]' ).append( 'Unread' ); }); "; } add_action('admin_footer-post.php', 'my_custom_status_add_in_post_page'); add_action('admin_footer-post-new.php', 'my_custom_status_add_in_post_page');

发布评论

评论列表(0)

  1. 暂无评论