我正在尝试创建一个只内联显示媒体库的帖子类型。
我从中得到了一个例子:https://gist.github.com/897503
但是,当我单击“插入图库”时,什么也没有发生。代码如下所示。
提前感谢!
add_action( \'init\', \'create_post_type_gallery\' );
function create_post_type_gallery() {
$args = array(
\'labels\' => post_type_labels( \'Gallery\', \'Galleries\' ),
\'public\' => true,
\'publicly_queryable\' => true,
\'register_meta_box_cb\' => \'my_gallery_meta_box\',
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'has_archive\' => false,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\',\'editor\' )
);
register_post_type( \'gallery\', $args );
}
function my_gallery_meta_box () {
add_meta_box(\'gallery_details\' , \'Media Library\', \'my_gallery_meta_box_details\', \'gallery\', \'normal\', \'high\' );
}
function my_gallery_meta_box_details () {
global $post;
$post_ID = $post->ID; // global used by get_upload_iframe_src
printf( "<iframe frameborder=\'0\' src=\' %s \' style=\'width: 100%%; height: 500px;\'> </iframe>", get_upload_iframe_src(\'media\') );
}