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.
define('MY_POST_TYPE', 'myslider');
  define('MY_POST_SLUG', 'myslider');

  function my_register_post_type () {
    $args = array (
        'label' => 'Gallery',
        'supports' => array( 'title', 'excerpt' ),
        'register_meta_box_cb' => 'my_meta_box_cb',
        'show_ui' => true,
        'orderby' => 'meta_value_num',
        'query_var' => true,
        'order'    => 'ASC',
        'public' => true,
        'publicly_queryable' => false,
        'show_in_menu' => true, 
        'capability_type' => 'post',
        'has_archive' => true, 
        'hierarchical' => true,
        'menu_position' => null,
    );
    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; // global used by get_upload_iframe_src
    printf( "<iframe frameborder='0' src=' %s ' style='width: 100%%; height: 400px;'> </iframe>", get_upload_iframe_src('media') );
  }
share|improve this question

2 Answers 2

I'm not so sure I understand your question but if I were to guess, this might help:

add_meta_box() Examples - WordPress Codex

share|improve this answer
up vote 0 down vote accepted

Working perfect :)

///////// Create attachment custom fields ///////////////////// function be_attachment_field_credit( $form_fields, $post ) { $form_fields['custom6'] = array( 'label' => 'Custom6 Name', 'input' => 'text', 'value' => get_post_meta( $post->ID, 'custom6', true ), 'helps' => 'custom6 Text', );

$form_fields['custom7'] = array(
    'label' => 'Custom7 URL',
    'input' => 'text',
    'value' => get_post_meta( $post->ID, 'custom7', true ),
    'helps' => 'custom7 link',
);


return $form_fields;

}

add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );

///////// attachment custom fields Saving /////////////////////

function be_attachment_field_credit_save( $post, $attachment ) { if( isset( $attachment['custom6'] ) ) update_post_meta( $post['ID'], 'custom6', $attachment['custom6'] );

if( isset( $attachment['custom7'] ) )
    update_post_meta( $post['ID'], 'custom7', $attachment['custom7'] );


return $post;

}

share|improve this answer

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.