2011-06-06 5 views
8

मेरी वर्डप्रेस विषय के functions.php में, मैं एक कस्टम पोस्ट प्रकार foobar बुलाया बना लिया है। क्या foobar पदों के लिए डिफ़ॉल्ट श्रेणियों और टैग का पुन: उपयोग करना संभव है? या क्या मुझे दो टैक्सोनोमी बनाना है - एक श्रेणियों के लिए और दूसरा टैग के लिए - इसे प्राप्त करने के लिए?कस्टम पोस्ट प्रकार के लिए डिफ़ॉल्ट श्रेणियों/टैग टैक्सोनोमी का पुन: उपयोग करें?

संपादित करें: मुझे लगता है मैं समारोह है कि कस्टम पोस्ट प्रकार बनाता है के भीतर इस कोड का उपयोग करके इस हल किया है:

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

मैं राज करते हैं।

+0

मैं सवाल अपने आप उत्तर दिया है। मेरे लिए केक! – CaseTA

+4

आप वास्तव में नीचे अपने प्रश्न का उत्तर दे सकते हैं (और इसे स्वीकार करते हैं)। दूसरों के लिए सहायक, क्योंकि यह हल हल सवाल को चिह्नित करता है। एक अलग रूप में आप अपने आप को कुछ प्रतिनिधि मिल के रूप में ... –

+0

Lol, मैंने इसे पढ़ा और मैं "तो क्या समस्या" अपने आप को करने के लिए सोचा ...। फिर मैंने आपकी टिप्पणियां पढ़ीं। –

उत्तर

5

आप एक तीर से दो पक्षियों को मारने और taxonomies कुंजी जब registering the post type उपयोग कर सकते हैं:

$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); 
संबंधित मुद्दे