Add metabox (yes/no select) to media attachment edit page
// add metabox to attachment edit page that will allow users to choose if to show this image in logo gallery
function add_our_attachment_meta(){
add_meta_box( 'custom-attachment-meta-box',
'Дополнительные настройки медиафайла',
'attachment_metabox_callback',
'attachment',
'normal',
'low'
);
}
add_action( 'admin_init', 'add_our_attachment_meta' );
function attachment_metabox_callback(){
global $post;
$value = get_post_meta($post->ID, 'featured_logo', 1);
echo '
<label for="featured_logo">Отображать эту картинку в галерее логотипов на главной странице? </label>
<select name="featured_logo" id="featured_logo">
<option value="0" '.selected( $value, 0, false ).'>Нет </option>
<option value="1" '.selected( $value, 1, false ).'>Да </option>
</select>
';
}
function save_our_attachment_meta(){
global $post;
if( isset( $_POST['featured_logo'] ) ){
update_post_meta( $post->ID, 'featured_logo', $_POST['featured_logo'] );
}
}