2
我有一個問題,將元框放入用插件創建的自定義帖子類型中。Wordpress add_meta_box在類中不工作時的自定義帖子類型
我已經經歷了上百次的代碼,開始懷疑類是否會產生影響,請問array($this, 'insT_tag')
作爲回調參考嗎?
我真的不明白什麼是錯的!我有一個我用來創建類型的代碼的示例,然後添加元框。有沒有人有任何想法?
function init_custom_post_types() {
register_post_type('inGallery', array(
'labels' => array(
'name' => __('inGalleries', 'inGallery'),
'singular_name' => 'inGallery',
'add_new' => 'Add new inGallery',
'add_new_item' => 'Add new inGallery',
'edit_item' => 'Edit inGallery',
'new_item' => 'New inGallery',
'view_item' => 'Show inGallery',
'search_items' => 'Search inGallery',
'not_found' => 'Not found',
'not_found_in_trash' => 'No inGallery was found in trash',
'parent_item_colon' => 'Parent:'
),
'public' => true,
'exclude_from_search' => false,
'query_var' => true,
'capability_type' => 'post',
'show_in_nav_menus' => true,
'menu_position' => 5,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'revisions'),
'taxonomies' => array('category', 'post_tag'),
'rewrite' => array('slug' => 'in', 'with_front' => false),
'publicly_queryable' => true,
'exclude_from_search' => false,
'can_export' => true,
'register_meta_box_cb' => array($this , 'add_inGallery_metaboxes')
));
// Add the custom type to the homepage post loop
add_filter('pre_get_posts', array($this, 'customTypeToPosts'));
}
public function add_inGallery_metaboxes() {
add_meta_box('insT_tag', 'Hash Tag', array($this, 'insT_tag'), 'inGallery', 'side', 'high' , array('tester'));
}
public function insT_tag ($a) {
print_r($a);
echo'<input type="text" value="tester"/>';
}