Getting Started

Creating a simple meta box

After installing and activating the Meta Box plugin, open your theme’s functions.php file (or a PHP file of your plugin) and insert the following code:

add_filter( 'rwmb_meta_boxes', 'your_prefix_meta_boxes' );
function your_prefix_meta_boxes( $meta_boxes ) {
    $meta_boxes[] = array(
        'title'      => __( 'Test Meta Box', 'textdomain' ),
        'post_types' => 'post',
        'fields'     => array(
                'id'   => 'name',
                'name' => __( 'Name', 'textdomain' ),
                'type' => 'text',
                'id'      => 'gender',
                'name'    => __( 'Gender', 'textdomain' ),
                'type'    => 'radio',
                'options' => array(
                    'm' => __( 'Male', 'textdomain' ),
                    'f' => __( 'Female', 'textdomain' ),
                'id'   => 'email',
                'name' => __( 'Email', 'textdomain' ),
                'type' => 'email',
                'id'   => 'bio',
                'name' => __( 'Biography', 'textdomain' ),
                'type' => 'textarea',
    return $meta_boxes;

Then go to Posts | Add New, you will see a new meta box appears below the post editor:

meta box


The Meta Box is made for WordPress developers and users who know a little coding. The core FREE version doesn’t have any UI in the admin for you to create and manage custom meta boxes and custom fields. Instead of that, it provides you a powerful API to quickly add custom fields to the editing pages. In order to do that, you need to define meta boxes and custom fields by code. That’s how we’ve just done above.

If you prefer UI to create and manage custom meta boxes and custom fields or you don’t want to touch code, we already made some extensions for you:

  • MB Custom Post Type: Create and manage custom post types and custom taxonomies with nice UI
  • Meta Box Builder: Create and manage custom meta boxes and custom fields with drag and drop UI.

More fields and demos

The Meta Box plugin has a list of demos which you can use as a starting point for your projects. The list is constantly updated with the new features or new demos in every new release of the plugin.

Firstly, you should start with demo.php by downloading it here. It is basic and has all explanations in comments (please read them carefully to understand how to write the script correctly).

Here are steps to integrate the demo.php into your theme:

  • Copy demo.php file to your theme folder
  • Open functions.php file of your theme and add the following code: include 'demo.php';

Now go to Add New Post page and see the result. If everything is ok, you’ll see as the following screenshots:

Meta Box

More documentation

To customize fields and meta boxes, please look at the documentation page of the plugin. Note that the documentation is regularly updated to cover the latest features of the plugin, so keep checking it when you have any troubles using the plugin.

Save > 70% when buy all extensions with Core Extension Bundle!

Introducing Affiliate Program! Read more