Wordpress 是否为自定义帖子类型重新使用默认类别/标签分类法?

Wordpress 是否为自定义帖子类型重新使用默认类别/标签分类法?,wordpress,wordpress-theming,Wordpress,Wordpress Theming,在我的wordpress主题的functions.php中,我创建了一个名为foobar的自定义帖子类型。是否可以重复使用foobar帖子的默认类别和标签?或者我必须创建两个分类法——一个用于类别,另一个用于标记——才能实现这一点 编辑:我想我已经通过在创建自定义帖子类型的函数中使用以下代码解决了这个问题: register_taxonomy_for_object_type('category', 'foobar'); register_taxonomy_for_object_type('pos

在我的wordpress主题的functions.php中,我创建了一个名为foobar的自定义帖子类型。是否可以重复使用foobar帖子的默认类别和标签?或者我必须创建两个分类法——一个用于类别,另一个用于标记——才能实现这一点

编辑:我想我已经通过在创建自定义帖子类型的函数中使用以下代码解决了这个问题:

register_taxonomy_for_object_type('category', 'foobar');
register_taxonomy_for_object_type('post_tag', 'foobar');

我来决定。

你可以一箭双雕,在下列情况下使用
分类法
键:


我自己已经回答了这个问题。给我蛋糕!你可以在下面回答你自己的问题(并接受它)。对其他人有帮助,因为它标志着问题的解决。顺便说一句,你给自己找了一些机会……哈哈,我读了之后,我想……“那有什么问题呢”。然后我读了你的评论。
$product_labels = array(
        'name' => _x('Products', 'post type general name'),
        'singular_name' => _x('Product', 'post type singular name'),
        'add_new' => _x('Add New', 'portfolio item'),
        'add_new_item' => __('Add New Product'),
        'edit_item' => __('Edit Product'),
        'new_item' => __('New Product'),
        'view_item' => __('View Product'),
        'search_items' => __('Search Products'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    );
    $product_args = array(
        'labels' => $product_labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array('slug' => 'product'),
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => 2,
        'supports' => array('title','editor', 'author', 'thumbnail', 'excerpt', 'comments', 'revisions', 'page-attributes', 'custom-fields', ),
        // Set the available taxonomies here
        'taxonomies' => array('category', 'post_tag') 
    );
    register_post_type('product', $product_args);