我有一个插件,可以创建自定义的帖子类型。然而,它不会创建存档或使单个帖子可见,我想对此进行更改。
这是注册帖子类型的代码:
private static function init_taxonomy() {
$show_in_menu = current_user_can( \'manage_woocommerce\' ) ? \'woocommerce\' : $show_in_menu = true;
register_post_type( \'wc_product_retailer\',
array(
\'labels\' => array(
\'name\' => __( \'Retailers\', \'woocommerce-product-retailers\' ),
\'singular_name\' => __( \'Retailer\', \'woocommerce-product-retailers\' ),
\'menu_name\' => _x( \'Retailers\', \'Admin menu name\', \'woocommerce-product-retailers\' ),
\'add_new\' => __( \'Add Retailer\', \'woocommerce-product-retailers\' ),
\'add_new_item\' => __( \'Add New Retailer\', \'woocommerce-product-retailers\' ),
\'edit\' => __( \'Edit\', \'woocommerce-product-retailers\' ),
\'edit_item\' => __( \'Edit Retailer\', \'woocommerce-product-retailers\' ),
\'new_item\' => __( \'New Retailer\', \'woocommerce-product-retailers\' ),
\'view\' => __( \'View Retailers\', \'woocommerce-product-retailers\' ),
\'view_item\' => __( \'View Retailer\', \'woocommerce-product-retailers\' ),
\'search_items\' => __( \'Search Retailers\', \'woocommerce-product-retailers\' ),
\'not_found\' => __( \'No Retailers found\', \'woocommerce-product-retailers\' ),
\'not_found_in_trash\' => __( \'No Retailers found in trash\', \'woocommerce-product-retailers\' ),
),
\'description\' => __( \'This is where you can add new product retailers that you can add to products.\', \'woocommerce-product-retailers\' ),
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'post\',
\'capabilities\' => array(
\'publish_posts\' => \'manage_woocommerce_product_retailers\',
\'edit_posts\' => \'manage_woocommerce_product_retailers\',
\'edit_others_posts\' => \'manage_woocommerce_product_retailers\',
\'delete_posts\' => \'manage_woocommerce_product_retailers\',
\'delete_others_posts\' => \'manage_woocommerce_product_retailers\',
\'read_private_posts\' => \'manage_woocommerce_product_retailers\',
\'edit_post\' => \'manage_woocommerce_product_retailers\',
\'delete_post\' => \'manage_woocommerce_product_retailers\',
\'read_post\' => \'manage_woocommerce_product_retailers\',
),
\'publicly_queryable\' => true,
\'exclude_from_search\' => true,
\'show_in_menu\' => $show_in_menu,
\'hierarchical\' => false,
\'rewrite\' => false,
\'query_var\' => false,
\'supports\' => array( \'title\' ),
\'show_in_nav_menus\' => false,
)
);
}
这是我在函数中使用的代码。我的孩子主题的php。
function change_post_types_slug( $args, $post_type ) {
/*item post type slug*/
if ( \'wc_product_retailer\' === $post_type ) {
$args[\'has_archive\'] = true;
}
return $args;
}
add_filter( \'register_post_type_args\', \'change_post_types_slug\', 10, 2 );
这不会改变任何事情。
此外,我还尝试通过添加
\'has_archive\' => true,
下方
\'show_in_nav_menus\' => false,
然后甚至改变
show_in_nav_menus
和query_vars
为真。
背景rewrite
“我的酷零售商”。
所有这些更改我都转到peramlinks设置并点击save。我甚至禁用了插件并重新启用了它。
此外,在post edit屏幕上,标题下仍不显示post slug。