Skip to main content

Shortcode

Besides normal ways to display fields on the website, Meta Box also provides a simple shortcode [rwmb_meta] to help you show custom fields in the post content or widgets easily.

[rwmb_meta id="field_id" object_id="15"]

Attributes

AttributeDescription
idThe field ID. Required.
object_idThe object ID. Optional. If not defined, then the current object ID is used.
attributeGet a single attribute from the field value (such as URL of the image or term slug). The field value is get with the rwmb_get_value() helper function. This works only when the value is an array.
render_shortcodeWhether to render inner shortcodes inside the value of the field. For example, if you enter a shortcode in a textarea/editor field, this attribute will render that shortcode and return the rendered content. Default true.

This shortcode works exactly like the rwmb_the_value() function with the same parameters.

Other attributes

You can pass other attributes to the shortcode if you want. If you do so, those attributes will be passed to the rwmb_the_value() function as the 2nd parameter.

Examples

Getting the value of a text field:

[rwmb_meta id="phone"]

Getting image URL (single_image):

[rwmb_meta id="company_logo" attribute="url" size="thumbnail"]

Getting a term meta:

[rwmb_meta id="color" object_id="15" object_type="term"]

Getting a settings:

[rwmb_meta id="phone" object_id="site_option" object_type="setting"]

Getting a field value from a custom table:

[rwmb_meta id="area" object_id="15" storage_type="custom_table" table="properties"]