我创建了一个自定义帖子类型“服务”。我想上传和嵌入两个不同的库。我研究并获得了各种代码来创建元框,从中可以上传图像。
但问题是,我只能在一个元框中上传一幅图像,而不能上传整个图库。
请帮我解决这个问题,或者建议我其他的选择
<?php
/*
Plugin Name: Services
Plugin URI:
Description: post types
Author: Amritanshu Kalia
Author URI:
License: GPLv2 or later
*/
define( \'ROOT\', plugins_url( \'\', __FILE__ ) );
define( \'STYLES\', ROOT . \'/css/\' );
define( \'SCRIPTS\', ROOT . \'/js/\' );
// Registers the new post type and taxonomy
function wpt_services_posttype() {
register_post_type( \'services\',
array(
\'labels\' => array(
\'name\' => __( \'Services\' ),
\'singular_name\' => __( \'services\' ),
\'add_new\' => __( \'Add New services\' ),
\'add_new_item\' => __( \'Add New services\' ),
\'edit_item\' => __( \'Edit service\' ),
\'new_item\' => __( \'Add New service\' ),
\'view_item\' => __( \'View service\' ),
\'search_items\' => __( \'Search service\' ),
\'not_found\' => __( \'No services found\' ),
\'not_found_in_trash\' => __( \'No services found in trash\' )
),
\'public\' => true,
\'supports\' => array( \'title\',\'thumbnail\', \'comments\',\'page-attributes\' ),
\'capability_type\' => \'post\',
\'rewrite\' => array("slug" => "services"), // Permalinks format
\'menu_position\' => 6,
\'register_meta_box_cb\' => \'add_services_metaboxes\',
\'show_ui\'=>true,
\'query_var\'=>true
)
);
}
add_action( \'init\', \'wpt_services_posttype\' );
/*Now we add the meta boxes to the services*/
add_action(\'add_meta_boxes\', \'add_services_metaboxes\');
function add_services_metaboxes() {
add_meta_box( \'services\' . \'_details\' , \'Media Library\', \'my_meta_box_details\', \'services\', \'normal\', \'high\' );
}
function my_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: 400px;\'> </iframe>", get_upload_iframe_src(\'media\') );
}
?>