duanmao1975 2015-04-03 14:26
浏览 17

具有自定义状态的WordPress帖子需要在所有视图中显示

I've built a WooCommerce plugin with a particular feature that stopped working right after I upgraded WordPress from 3.8 to 4.1 and WooCommerce from 1 to 2.2. I had added the dg_order post type, which is similar to the WooCommerce shop_order and shares statuses (processing, completed, etc.). My problem is on the admin table for the posts. Right now, the status views at the top of the table read "All (14) | Completed (14)". However, I see "No DG Orders found" under All. Completed does show the orders appropriately. Here's the post type definition:

function dm_inv_dg_post_type () {
    $show_in_menu = current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true;

    register_post_type( "dg_order", array(
            'labels' => array(
                    'name'                  => __( 'DG Orders', 'woocommerce' ),
                    'singular_name'         => __( 'DG Order', 'woocommerce' ),
                    'add_new'               => __( 'Add Order', 'woocommerce' ),
                    'add_new_item'          => __( 'Add New DG Order', 'woocommerce' ),
                    'edit'                  => __( 'Edit', 'woocommerce' ),
                    'edit_item'             => __( 'Edit Order', 'woocommerce' ),
                    'new_item'              => __( 'New DG Order', 'woocommerce' ),
                    'view'                  => __( 'View Order', 'woocommerce' ),
                    'view_item'             => __( 'View Order', 'woocommerce' ),
                    'search_items'          => __( 'Search DG Orders', 'woocommerce' ),
                    'not_found'             => __( 'No DG Orders found', 'woocommerce' ),
                    'not_found_in_trash'    => __( 'No DG Orders found in trash', 'woocommerce' ),
                    'parent'                => __( 'Parent Orders', 'woocommerce' ),
                    'menu_name'             => _x('DG Orders', 'Admin menu name', 'woocommerce')
                ),
            'description'           => __( 'This is where orders to DG are stored.', 'woocommerce' ),
            'public'                => false,
            'show_ui'               => true,
            'capability_type'       => 'shop_order',  
            'map_meta_cap'          => true,
            'publicly_queryable'    => false,
            'exclude_from_search'   => true,
            'show_in_menu'          => $show_in_menu,
            'hierarchical'          => false,
            'show_in_nav_menus'     => false,
            'rewrite'               => false,
            'query_var'             => false,
            'supports'              => array( 'title', 'comments' ),
            'has_archive'           => false,
        )
    );
}
add_action('init', 'dm_inv_dg_post_type', 12);

The WooCommerce upgrade changed how the statuses are stored (as an actual post status instead of taxonomy terms), so that likely has something to do with it. I thought it might have something to do with the show_in_admin_all_list parameter for register_post_status, but the WooCommerce developers set that to true, and the correct number of completed orders show up in the All count.

Any thoughts?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 vue3加ant-design-vue无法渲染出页面
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决
    • ¥15 processing提取音乐节奏
    • ¥15 gg加速器加速游戏时,提示不是x86架构
    • ¥15 python按要求编写程序