Home / admin / Display a custom post type’s media library inline
  • How to Display a custom post type’s media library inline

    display-a-custom-post-types-media-library-inline

    Adding this snippet to the functions.php of your wordress theme will display a custom post type’s media library inline. This is a great little trick that will display the gallery using an iframe and will function exactly the same as the popup does.

    ( click code to copy )

    wordpress snippet : PHP

    <>
      define('MY_POST_TYPE', 'my');
      define('MY_POST_SLUG', 'gallery');
      function my_register_post_type () {
      	$args = array (
      		'label' => 'Gallery',
      		'supports' => array( 'title', 'excerpt','thumbnail' ),
      		'register_meta_box_cb' => 'my_meta_box_cb',
      		'show_ui' => true,
      		'query_var' => true
      	);
      	register_post_type( MY_POST_TYPE , $args );
      }
      add_action( 'init', 'my_register_post_type' );
      function my_meta_box_cb () {
      	add_meta_box( MY_POST_TYPE . '_details' , 'Media Library', 'my_meta_box_details', MY_POST_TYPE, 'normal', 'high' );
      }
      function my_meta_box_details () {
      	global $post;
        $post_ID = $post->ID;
      	printf( "<iframe frameborder='0' src=' %s ' style='width: 100%%; height: 400px;'> </iframe>", get_upload_iframe_src('media') );
      }
    

    ( WordPress codex functions, hooks, in this snippet. )

    register, query, init, register_post_type, register_meta, add_meta_box, add_action,
  • Anonymous

    If you want your booth to exude a sophisticated,
    polished style, consider soft flooring that mimics the look of a beautiful
    hardwood floor. If your company’s image is more fun loving, a custom trade show
    carpet in bold color blocks is a great choice. If you’re selling tools or auto
    parts, consider rubber matting from recycled tires – it’s durable and
    eco-friendly as well.

  • cudjex

    Thanks Kevin.

  • Francisco Javier Pardo Rebolle

    Thanks… very useful