2013-01-24 49 views
2

我有一個自定義元框(分類),這是定位在我的自定義帖子的一側。我想將它移動到正常位置,但是當我刪除它(remove_meta_box),並重新添加(add_meta_box)時,我只能得到酒吧,沒有選擇任何選項。我想我沒有寫適當的$回調,但我嘗試了很多變化,並沒有任何線索。WordPress的自定義分類移動meta_box

function create_isotope_taxonomies() 
{ 
    $labels = array(
    'name' => _x('Select Category', 'taxonomy general name'), 
    'singular_name' => _x('Category', 'taxonomy singular name'), 
    'search_items' => __('Search Categories'), 
    'popular_items' => __('Popular Categories'), 
    'all_items' => null, 
    'parent_item' => null, 
    'parent_item_colon' => null, 
    'edit_item' => __('Edit'), 
    'update_item' => __('Update'), 
    'add_new_item' => __('Add New'), 
    'new_item_name' => __('New Category'), 
    'separate_items_with_commas' => __('Separate writers with commas'), 
    'add_or_remove_items' => __('Add or remove categories'), 
    'choose_from_most_used' => __('Choose from the most used categories'), 
    'menu_name' => __('Categories'), 
); 

    register_taxonomy('fzisotope_categories','fzisotope_post',array(
    'hierarchical' => true, 
    'labels' => $labels, 
    'show_ui' => true, 
    'show_admin_column' => true, 
    'update_count_callback' => '_update_post_term_count', 
    'query_var' => true, 
    'rewrite' => array('slug' => 'fzisotope_categories'), 
)); 
} 



function fzisotope_categories_meta_box(){ 
remove_meta_box('fzisotope_categoriesdiv', 'fzisotope_post', 'side'); 
     add_meta_box('fzisotope_categoriesdiv', 'Select Category', 'fzisotope_categories_meta_box', 'fzisotope_post', 'normal', 'high'); 
     //print '<pre>';print_r($wp_meta_boxes['post']);print '<pre>'; 
} 
add_action('admin_init', 'fzisotope_categories_meta_box', 0); 

感謝您閱讀

回答

3

你必須使用: post_categories_meta_box與層次分類。

remove_meta_box('fzisotope_categoriesdiv', 'fzisotope_post', 'side'); 
add_meta_box('fzisotope_categoriesdiv', 'XXXXXXXXXXX', 'post_categories_meta_box', 'post', 'normal', 'high', array('taxonomy' => 'fzisotope_categories')); 
+0

如果您正在使用_custom文章type_進行此操作,您需要將** post **替換爲** custom_post_type_slug ** – GFargo

相關問題