Metabox is a developer's toolkit for building metaboxes, custom fields, and forms for WordPress that will blow your mind. Easily manage meta for custom post types.
You can see a list of available field types here.
- Place the metabox directory inside of your theme or plugin.
- Now include the metabox class
require dirname(__FILE__) . '/metabox/class-metabox.php';
.
add_action( 'admin_init', 'add_custom_metabox' );
function(add_custom_metabox){
$metabox = new \Pluginever\Framework\Metabox( 'html-id' );
$config = array(
'title' => __( 'Metabox Settings', 'wpcp' ),
'screen' => 'post',
'context' => 'normal',
'priority' => 'high',
'lazy_loading' => 'true',
'class' => 'custom-class',
'fields' => [
[
'type' => 'text',
'label' => __( 'Example Field', 'wpcp' ),
'name' => 'example_field',
'sanitize' => 'esc_html',
],
],
);
$metabox->init( $config );
}
- Profit.