0

I have a created a custom post type 'services'.I want to upload and embed two different galleries. I researched and got various codes to create meta boxes from where one can upload the image.

But the problem is that i am only able to upload only one image in one meta box and not the whole gallery.

Please help me out how can i do this or suggest me some another alternative

<?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') );
  }
?>  
  • Which code have you tried? – cybmeta Jan 4 '15 at 10:07
  • @cybmeta i have inserted the code above – terminator Jan 4 '15 at 10:18
  • Although your code may not be the best solution from my point of view, I don't understand why you say that you can upload only one image when actually you can upload an unlimited number of images. – cybmeta Jan 4 '15 at 11:00
  • @cybmeta i think you are right .. i am able to create the gallery but how do i display the gallery on the front end – terminator Jan 4 '15 at 11:28
  • Your code is storing the images as attached files of current post; this can help you. And please, edit the question to describe better your actual problem. – cybmeta Jan 4 '15 at 12:10
0

Embedded two galleries in the order according to my need. Then used the get_post_galleries to get the galleries in an array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.