2

我有一个自定义元框(分类法),位于我的自定义帖子的一侧。我想将它移动到正常位置,但是当我删除它(remove_meta_box)并重新添加(add_meta_box)时,我只得到 bar,没有选择任何东西的选项。我想我没有写正确的 $callback,但我尝试了很多变体,但没有任何线索。

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 );

谢谢阅读

4

1 回答 1

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' ));
于 2013-01-25T11:31:07.227 回答