File advanced not rendered correctly
- This topic has 2 replies, 2 voices, and was last updated 4 years, 1 month ago by
lucabi.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
March 28, 2021 at 9:40 PM #26770
lucabi
ParticipantHi, I've tried to add a File advanced field in a custom post type using the same example provided in documentation:
$meta_boxes[] = array( 'title' => 'File', 'post_types' => $this->post_type_name, 'fields' => array( 'id' => 'file', 'name' => 'File Advanced', 'type' => 'file_advanced', // Delete file from Media Library when remove it from post meta? // Note: it might affect other posts if you use same file for multiple posts 'force_delete' => false, // Maximum file uploads. 'max_file_uploads' => 2, // File types. // 'mime_type' => 'application,audio,video', // Do not show how many files uploaded/remaining. 'max_status' => 'false', 'multiple' => false ), );
but the control is rendered as 7 plain input controls.
I'm using WordPress 5.7. It makes no difference if I set Gutemberg or classic editor in the post type settings.
Kind regards, Luca
March 28, 2021 at 10:17 PM #26774Long Nguyen
ModeratorHi,
The
fields
key is an array of field arrays, it should be$meta_boxes[] = array( 'title' => 'File', 'post_types' => 'post', 'fields' => array( array( 'id' => 'file', 'name' => 'File Advanced', 'type' => 'file_advanced', // Delete file from Media Library when remove it from post meta? // Note: it might affect other posts if you use same file for multiple posts 'force_delete' => false, // Maximum file uploads. 'max_file_uploads' => 2, // File types. // 'mime_type' => 'application,audio,video', // Do not show how many files uploaded/remaining. 'max_status' => 'false', 'multiple' => false ), array( // another field ), ), );
Get more details on this basic documentation https://docs.metabox.io/creating-meta-boxes/.
March 28, 2021 at 10:45 PM #26776lucabi
ParticipantThank you very much, my fault sorry. The fact that something was rendered misled me.
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.