Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to create a post type which only displays the Media Library Inline.

I have got the example from this : https://gist.github.com/897503

However, nothing happens when I click "Insert Gallery". The code is as below.

Thanks in advanced!

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') );
}
share|improve this question
    
This is absolutely incomplete. Example: width: 100%% and the function post_type_labels() doesn't exist in core - you should get an error there. –  kaiser Jan 15 '12 at 19:55
    
post_type_labels function is created by me. No problem with that function. I am guessing the width is just part of css styling, should not be an issue –  Jack Jan 16 '12 at 4:49
    
Btw, the code above works! Just add 'editor' also in the supports. –  Jack Jan 16 '12 at 13:17
    
Yes. I was talking about the double %-character. –  kaiser Jan 16 '12 at 15:06
add comment

1 Answer 1

up vote 2 down vote accepted

Take a look at my Gallery Metabox plugin to see how to build one, or you could just use the plugin itself. There's a filter for specifying the post types it applies to.

share|improve this answer
    
Thanks. Plugin is cool. Anyway, the code above I pasted also does work :) My mistake on not allowing the editor. –  Jack Jan 16 '12 at 13:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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