Meta Box is a popular WordPress plugin that allows developers to easily create custom meta boxes and custom fields for posts, pages, custom post types, and user profiles. With Meta Box, you can add custom data fields for any post type, including text, image, file, select, and many more.
One of the main benefits of using Meta Box is its flexibility. It provides a wide range of field types and options, which enables developers to create custom fields that suit their specific needs. Additionally, Meta Box is built with developers in mind, it offers a wide range of developer-friendly options, such as custom sanitization, custom validation and custom storage, which can be set on a per-field basis.
Another great feature of Meta Box is its support for custom meta boxes, which allow developers to organize their fields into logical groups and to create custom fields with multiple sections, fields or sub fields. This makes it easy for developers to find the fields they need, and for clients to navigate the backend.
Meta Box also provides a wide range of advanced features such as the ability to create custom fields for options pages, media uploader and image cropping, repeater and flexible fields, and many more. These features enable developers to create complex and sophisticated custom fields, which can be used for a wide range of purposes.
Overall, Meta Box is a powerful and flexible plugin that is essential for any WordPress developer looking to add custom fields to their website. With its wide range of field types, developer-friendly options, and advanced features, Meta Box makes it easy to add custom data fields to your website, giving you more control over its functionality and making it more user-friendly for your clients.
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
$meta_boxes[] = [
'title' => 'Product Details',
'fields' => [
[
'name' => 'SKU',
'id' => 'sku',
'type' => 'text',
],
[
'name' => 'Price',
'id' => 'price',
'type' => 'number',
],
[
'name' => 'Enable Sale Price',
'id' => 'enable_sale_price',
'type' => 'checkbox',
],
[
'name' => 'Sale Price',
'id' => 'sale_price',
'type' => 'number',
'dependency' => [
'enable_sale_price' => '1',
],
],
[
'name' => 'Enable Stock Management',
'id' => 'enable_stock_management',
'type' => 'checkbox',
],
[
'name' => 'Stock',
'id' => 'stock',
'type' => 'number',
'dependency' => [
'enable_stock_management' => '1',
],
],
],
'post_types' => [ 'product' ],
];
return $meta_boxes;
} );
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
$meta_boxes[] = [
'title' => 'My Meta Box',
'fields' => [
[
'name' => 'Pages',
'id' => 'pages',
'type' => 'select_advanced',
'options' => [
'multiple' => true,
'args' => [
'post_type' => 'page',
'posts_per_page' => -1,
],
],
],
],
];
return $meta_boxes;
} );