我已经使用自定义插件注册了几个自定义帖子类型。它们似乎都很好用。所有都列在Post菜单下。
保存自定义帖子条目时出现问题。自定义的post类型保存在数据库中,permalink从前端就可以正常工作。但奇怪的是,自定义post类型表是空的。post状态过滤器显示“所有(1)|已发布(1)”。Screenshot
经过调查,我发现这种情况发生在第二次register_post_type()
在我的自定义插件中调用。
如何解决此问题?
非常感谢。
Added
这里是register\\u post\\u类型代码的2。它们中的每一个都是从不同的文件调用的,使用include_once (\'product/product.php\');
和include_once (\'order/order.php\');
add_action(\'init\', \'product_post_type\', 0 );
function product_post_type() {
$product_labels = array(
\'name\' => _x(\'Product\', \'post type general name\'),
\'singular_name\' => _x(\'Product\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'investment\'),
\'add_new_item\' => __(\'Add New Product\'),
\'edit_item\' => __(\'Edit Product\'),
\'new_item\' => __(\'New Product\'),
\'view_item\' => __(\'View Product\'),
\'search_items\' => __(\'Search Product\'),
\'not_found\' => __(\'No product found\'),
\'not_found_in_trash\' => __(\'No product found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Product\'
);
$product_args = array(
\'labels\' => $product_labels,
\'public\' => true,
\'can_export\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'product\' ),
\'capability_type\' => \'post\',
\'map_meta_cap\' => true,
\'has_archive\' => true,
\'hierarchical\' => true,
\'menu_position\' => 6,
\'show_in_nav_menus\' => false,
\'supports\' => array(\'title\',\'editor\',\'thumbnail\',\'comments\')
);
register_post_type(\'product\',$product_args);
}
add_action(\'init\', \'order_post_type\', 0 );
function order_post_type() {
$order_labels = array(
\'name\' => _x(\'Order\', \'post type general name\'),
\'singular_name\' => _x(\'Order\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'investment\'),
\'add_new_item\' => __(\'Add New Order\'),
\'edit_item\' => __(\'Edit Order\'),
\'new_item\' => __(\'New Order\'),
\'view_item\' => __(\'View Order\'),
\'search_items\' => __(\'Search Order\'),
\'not_found\' => __(\'No order found\'),
\'not_found_in_trash\' => __(\'No order found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Order\'
);
$order_args = array(
\'labels\' => $order_labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => true,
\'menu_position\' => 8,
\'supports\' => array(\'title\')
);
register_post_type(\'order\',$order_args);
}