2012-04-20 13 views
5

में टैग पैनल दिखाएं मैंने अभी एक कस्टम पोस्ट प्रकार बनाया है। मैं साइडबार क्या पोस्ट पोस्ट प्रकार है के रूप में ही पर टैग पैनल कैसे प्रदर्शित करते हैं?कस्टम पोस्ट प्रकार

+0

था तुम मुझे कोड आप तो में जोड़ा functions.php कस्टम पोस्ट प्रकार बनाने के लिए दिखा सकते हैं? –

उत्तर

10

इस लाइन

'taxonomies' => array('category', 'post_tag') 

पूरा कोड है अपने विषय फ़ोल्डर में functions.php में अनुभाग आप register_post_type में जोड़ने के लिए इस

add_action('init', 'create_post_type'); 
function create_post_type() { 
register_post_type('posttypename', 
     array(
      'labels' => array(
       'name' => __('PostTypeName'), 
       'singular_name' => __('PostTypeName') 
      ), 
      'public' => true, 
      'has_archive' => true, 
      'rewrite' => array('slug' => 'posttypename'), 
      'supports' => array('title', 'editor', 'excerpt', 'custom-fields', 'thumbnail'), 
      'taxonomies' => array('category', 'post_tag') // this is IMPORTANT 
     ) 
    ); 
} 
+0

यही वह था जिसे मैं ढूंढ रहा था: 'टैक्सोनोमीज़' => सरणी ('श्रेणी', 'post_tag') '। धन्यवाद, चंदू! – enchance

4

तरह लग रहा है आप 'taxonomies' => array('category', 'post_tag') तो वर्डप्रेस डिफ़ॉल्ट पोस्ट के टैग का उपयोग करते हैं कस्टम पोस्ट प्रकार क्षेत्र में प्रदर्शित किया जाएगा।

यहाँ "समाचार" पोस्ट type.No अन्य कस्टम पोस्ट प्रकार, डिफ़ॉल्ट टैग, .. आदि के साथ मिश्रण के लिए स्वच्छ और अनोखा तरीका है।

आप "create custom post types and tags with categories" from this link.

add_action('init', 'news_tag_taxonomies'); //change order add_action('init', 'news_tag_taxonomies', 0); 

//create two taxonomies, genres and tags for the post type "tag" 
function news_tag_taxonomies() 
{ 
    // Add new taxonomy, NOT hierarchical (like tags) 
    $labels = array(
    'name' => _x('Tags', 'taxonomy general name'), 
    'singular_name' => _x('Tag', 'taxonomy singular name'), 
    'search_items' => __('Search Tags'), 
    'popular_items' => __('Popular Tags'), 
    'all_items' => __('All Tags'), 
    'parent_item' => null, 
    'parent_item_colon' => null, 
    'edit_item' => __('Edit Tag'), 
    'update_item' => __('Update Tag'), 
    'add_new_item' => __('Add New Tag'), 
    'new_item_name' => __('New Tag Name'), 
    'separate_items_with_commas' => __('Separate tags with commas'), 
    'add_or_remove_items' => __('Add or remove tags'), 
    'choose_from_most_used' => __('Choose from the most used tags'), 
    'menu_name' => __('Tags'), 
); 

    register_taxonomy('tag','news',array(// replace your post type with "news" 
    'hierarchical' => false, 
    'labels' => $labels, 
    'show_ui' => true, 
    'update_count_callback' => '_update_post_term_count', 
    'query_var' => true, 
    'rewrite' => array('slug' => 'tag'), 
)); 
} 

आशा इस मदद होगा का पूरा विवरण का पालन कर सकते हैं।

+1

धन्यवाद ... यह बहुत उपयोगी था – mostafaznv

1

सभी मैं डिफ़ॉल्ट WP कोडेक्स टेम्पलेट से अलग जोड़ने की जरूरत

'taxonomies' => array('post_tag'),  
संबंधित मुद्दे