Wordpress 设置为使用不同的主帖子类型
我有一个现有的网站,我需要添加商业问题。网站functions.php和其他模板文件是使用某种目录构建的:Wordpress 设置为使用不同的主帖子类型,wordpress,woocommerce,Wordpress,Woocommerce,我有一个现有的网站,我需要添加商业问题。网站functions.php和其他模板文件是使用某种目录构建的: function register_product() { $labels = array( 'name' => _x('Catalog', 'post type general name','LADS'), 'singular_name' => _x('Product', 'post type singular name','LADS'
function register_product() {
$labels = array(
'name' => _x('Catalog', 'post type general name','LADS'),
'singular_name' => _x('Product', 'post type singular name','LADS'),
'add_new' => _x('Add','LADS'),
'add_new_item' => __('Add','LADS'),
'edit_item' => __('Edit','LADS'),
'new_item' => __('Add','LADS'),
'all_items' => __('All','LADS'),
'view_item' => __('View','LADS'),
'search_items' => __('Search','LADS'),
'not_found' => __('Nothing Found','LADS'),
'not_found_in_trash' => __('Nothing Found','LADS'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'catalog' ),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'taxonomies' => 'product_category',
'supports' => array('title','editor','thumbnail','excerpt','comments','revisions','custom-fields')
);
register_post_type( 'product' , $args );
}
add_action('init', 'register_product');
完整代码部分如下:
目录使用的是WP post类型“product”,这使得它显示目录条目,它们与WooCommerce冲突,因为默认情况下它使用的是相同的post名称
是否可以强制WooCommerce在默认情况下使用不同的帖子类型?例如“product1”这可能会有帮助,谢谢@ozgur,但我不确定情况是否相同。在我的情况下,网站上已经发布了1000多个目录条目,在帖子类型“product”和激活WooCommerce下,它认为它们是WooCommerce的产品,这使得一切都错了。删除这些条目不是一个选项,我不知道重写现有代码是否会有帮助,因为我仍然需要将它们迁移到另一个帖子类型名称。这可能会有帮助,谢谢@ozgur,但我不确定情况是否相同。在我的情况下,网站上已经发布了1000多个目录条目,在帖子类型“product”和激活WooCommerce下,它认为它们是WooCommerce的产品,这使得一切都错了。删除这些条目不是一个选项,我不知道重写现有代码是否有帮助,因为我仍然需要将它们迁移到另一个帖子类型名称。