Get custom field value and display in the frontend

To get field meta value, use this function:

rwmb_meta( $field_id, $args = array(), $post_id = null );

To display field value in the frontend, just put the code below in your theme’s template file:

<?php echo rwmb_meta( $field_id, $args, $post_id ); ?>

You can omit $args and/or $post_id. In that case, the function will return simple value (for text, radio, select) for current post.

For complicated field, please see the arguments below.


Name Description
$field_id The field ID.
$args Array of arguments or a string in format param=value1&amp;param2=value2. See table below for list of supported arguments.
$post_id Post ID. Optional. If not present, current post ID is used.

List of supported arguments for $args:

Argument Description
type Field type. Default is text. You can bypass this attribute if your field has single value (e.g. not multiple, not clone). Required for field which is multiple or clone (checkbox_list, file and image fields, taxonomy, etc.).
multiple If field has multiple values (like select with multiple selections), set this argument to true. It’s automatically set to true for checkbox_list, file and image fields.
size Image size, used for image fields only. If not present, the thumbnail size will be used.
taxonomy The taxonomy for which to retrieve terms, used for taxonomy fields.

Returned value

Single value

For fields that have single value (text, radio, checkbox, etc.) the function acts exactly like get_post_meta( $post_id, $key, true ). It returns the value of the field.

Multiple values

For fields that have multiple values (checkbox_list, select with multiple = true) the function acts exactly like get_post_meta( $post_id, $key, false ). It returns an array of values of the field.


For file fields, the function returns an array of files, each file has the following information:

    'name'  => 'intro.txt',
    'path'  => '/var/www/wp-content/uploads/intro.txt',
    'url'   => '',
    'title' => 'Introduction',

Note: Don’t forget to specify type=file in $args.


For image fields, the function returns an array of images, each image has the following information:

    'name'        => 'logo-150x80.png',
    'path'        => '/var/www/wp-content/uploads/logo-150x80.png',
    'url'         => '',
    'width'       => 150,
    'height'      => 80,
    'full_url'    => '',
    'title'       => 'Logo',
    'caption'     => 'Logo caption',
    'description' => 'Used in the header',
    'alt'         => 'Logo ALT text',

The information is attached with a specific image size, so don’t forget to add size=your_size in $args. Otherwise, you’ll get the information for thumbnail size.

There’s one argument in the returned array that you might be interested in: full_url. It’s the URL of full size image (original image). You can use it for lightbox effect or in a slider with thumbnails.

Note: all image fields act exactly like image, so you can write both type=image or type=plupload_image in $args, the function returns the same value.


Display date of birth (date):

echo rwmb_meta( 'dob' );

Display list of interests (checkbox_list):

$interests = rwmb_meta( 'interests', 'type=checkbox_list' );
echo implode( ', ', $interests );

Display links to download uploaded files (file):

$files = rwmb_meta( 'info', 'type=file' );
foreach ( $files as $info )
    echo "<a href='{$info['url']}' title='{$info['title']}'>{$info['name']}</a><br />";

Display uploaded images in thickbox (image):

$images = rwmb_meta( 'gallery', 'type=image&size=YOURSIZE' );
foreach ( $images as $image )
    echo "<a href='{$image['full_url']}' title='{$image['title']}' rel='thickbox'><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></a>";

Display list of terms (taxonomy type):

$terms = rwmb_meta( '', 'type=taxonomy&taxonomy=tax_slug' );
$content = '<ul>';
foreach ( $terms as $term )
    $content .= sprintf(
        '<li><a href="%s" title="%s">%s</a></li>',
        get_term_link( $term, 'tax_slug' ),
$content .= '</ul>';
echo $content;

Grab the core extensions bundle today and save over 60%!