WordPress OSINT, maintenance or security needs? Reach out!
TLDWP

Plugin: display-a-meta-field-as-block (Used by 560 domains)

Meta Field Block

πŸ‘€ Phi Phan πŸ“¦ v1.5.2 πŸ”— Plugin Homepage

This single-block plugin allows you to display a meta field or a custom field as a block on the front end. It supports custom fields for posts, terms, and users. It can be nested inside a parent block that has postId and postType context, such as Query Block, WooCommerce Product Collection, or used as a stand-alone block.

You can display any field whose value can be retrieved by the core API (get_post_meta, get_term_meta, get_user_meta) and is a string or can be converted to a string. To display the field value in the Block Editor, it has to be accessible via the REST API or have the field type set to dynamic.

You can also display custom fields created by the Advanced Custom Fields or Meta Box plugin explicitly. It supports all ACF field types and Meta Box field types whose values are strings or can be converted to strings. Some other ACF complex fields such as Image, Link, Page Link, True False, Checkbox, Select, Radio, Button Group, Taxonomy, User, Post Object and Relationship field types as well as Meta Box fields such as Select, Checkbox, Radio, Image, Video, Taxonomy, User, Post field types are also supported in basic formats.

This plugin also provides developer-friendly hook APIs that allow you to easily customize the output of the block, display complex data type fields, or use the block as a placeholder to display any kind of content with object_id and object_type as context parameters.

An edge case where this block is really helpful is when you need to get the correct post_id in your shortcode when you use it in a Query Loop. In that case, you can set the field type as dynamic and input your shortcode in the field name. The block will display it correctly on both the front end and the editor. Alternatively, if you only want to see the preview of your shortcode in the editor, you can also use this block as a better version of the core/shortcode.

To quickly learn how this block displays custom fields, watch the short guide (for MFB version 1.3.4) by Paul Charlton from WPTuts. The video focuses on the Advanced Custom Fields plugin, but you can use a similar approach to display fields from other frameworks like Meta Box.

Links

What is the HTML output of a custom field?

The HTML output of a custom field on the front end depends on the context of the field. It uses one of these core API functions to get the field value: get_post_meta, get_term_meta, get_user_meta.

What is the HTML output of ACF fields?

  1. All basic field types that return strings or can cast to strings are supported – The HTML output is from the get_field function.

  2. Link type – The HTML output is:

    {title}
    

    There is no rel attribute if the target is not _blank

  3. Image type – The HTML output is from the wp_get_attachment_image function. The image size is from the Preview Size setting.

  4. True / False type – The HTML output is Yes if the value is true, and No if the value is false. Below is the code snippet to change these text values:

    add_filter( 'meta_field_block_true_false_on_text', function ( $on_text, $field_name, $field, $post_id, $value ) {
      return 'Yep';
    }, 10, 5 );
    
    add_filter( 'meta_field_block_true_false_off_text', function ( $off_text, $field_name, $field, $post_id, $value ) {
      return 'Noop';
    }, 10, 5 );
    
  5. Checkbox / Select type – The HTML output is:

    {item_value}, {item_value}
    

    The item_value can be either value or label, depending on the return format of the field. Multiple selected values are separated by ,. Below is the code snippet to change the separator:

    add_filter( 'meta_field_block_acf_field_choice_item_separator', function ( $separator, $field_name, $field, $post_id, $value ) {
      return ' | ';
    }, 10, 5 );
    
  6. Radio button / Button group type – The HTML output can be either value or label, depending on the return format of the field.

  7. Page link type, Post object type – The HTML output for a single-value field is:

    {title}
    

    For a multiple-value field is:

    
    
  8. Relationship type – The HTML output is:

    
    
  9. Taxonomy type – The HTML output is:

    
    
  10. User type – The HTML output for a single-value field is:

    {display_name}
    

    For a multiple-value field is:

    
    
  11. For other complex field types, you can generate a custom HTML output by using the hook:

    apply_filters( 'meta_field_block_get_acf_field', $field_value, $post_id, $field, $raw_value, $object_type )
    

    Or by using the general hook:

    apply_filters( 'meta_field_block_get_block_content', $content, $attributes, $block, $object_id, $object_type )
    

What is the HTML output of Meta Box fields?

  1. Similar to ACF fields, all basic fields that return strings or can cast to strings using the function rwmb_get_value are supported.

    The HTML output of cloneable basic fields is:

    {item_1_value}, {item_2_value}
    

    Use the following hooks to change the tag and the separator:

    apply_filters( 'meta_field_block_mb_clone_field_item_separator', ', ', $field, $post_id, $field_value )
    apply_filters( 'meta_field_block_mb_clone_field_item_tag', 'span', $field, $post_id, $field_value )
    
  2. Single image types – The HTML output is from the wp_get_attachment_image function. The image size is from the image_size setting.

  3. Image list types (Image, Image advanced, Image upload) – The HTML output is:

  4. Checkbox / Switch type – Similar to ACF True / False type.

  5. Multi-choice types (Select, Select advanced, Button group, Autocomplete, Image select, Checkbox list) – The HTML output is:

    {item_value}, {item_value}
    

    To display the label instead of the value, use this hook:

    apply_filters( 'meta_field_block_mb_field_choice_item_display_label', false, $field_name, $field, $post_id, $value )
    

    To change the separator, use this hook:

    apply_filters( 'meta_field_block_mb_field_choice_item_separator', ', ', $file_name, $field, $post_id, $value )
    
  6. Radio type – The output is the field value by default. To display label or change the separator, use the same hooks as the multi-choice types.

  7. Post type – The HTML output for a single-value field is:

    {title}
    

    For a multiple-value field is:

    
    
  8. Taxonomy, Taxonomy advanced type – The HTML output for a single-value field is:

    {term_name}
    

    For a multiple-value field is:

    
    
  9. User type – Similar to ACF User type

  10. Video type – The HTML output for a single-value field is:

    For a multiple-value field is:

  11. To display complex field types or change the output of a field, use the hook meta_field_block_get_mb_field or the general hook meta_field_block_get_block_content.

Copy & paste snippets

When using the meta_field_block_get_block_content hook to customize block content, we recommend selecting dynamic as the field type. This way, both the front end and the editor will show the changes. If you are working with ACF Fields, we suggest using the meta_field_block_get_acf_field hook to modify the field content. Similarly, Meta Box users should use the meta_field_block_get_mb_field hook to modify the content. ACF snippets can also be used with Meta Box fields, but you must use the correct hook name and replace the get_field function with the rwmb_get_value function.

  1. How to change the HTML output of the block?
    Using the meta_field_block_get_block_content hook:

    add_filter( 'meta_field_block_get_block_content', function ( $block_content, $attributes, $block, $post_id, $object_type ) {
      $field_name = $attributes['fieldName'] ?? '';
    
      if ( 'your_unique_field_name' === $field_name ) {
        $block_content = 'new content';
      }
    
      return $block_content;
    }, 10, 5);
    

    Using the meta_field_block_get_acf_field hook for ACF Fields only:

    add_filter( 'meta_field_block_get_acf_field', function ( $block_content, $post_id, $field, $raw_value, $object_type ) {
      $field_name = $field['name'] ?? '';
    
      if ( 'your_unique_field_name' === $field_name ) {
        $block_content = 'new content';
      }
    
      return $block_content;
    }, 10, 5);
    

    This basic snippet is very powerful. You can use it to display any fields from any posts, terms, users or setting fields. Please see the details in the below use cases.

  2. How to wrap the block with a link to the post within the Query Loop?
    Using the meta_field_block_get_block_content hook:

    add_filter( 'meta_field_block_get_block_content', function ( $block_content, $attributes, $block, $post_id ) {
      $field_name = $attributes['fieldName'] ?? '';
    
      if ( 'your_unique_field_name' === $field_name && $block_content !== '' ) {
        $block_content = sprintf('%2$s', get_permalink($post_id), $block_content);
      }
    
      return $block_content;
    }, 10, 4);
    

    Using the meta_field_block_get_acf_field hook for ACF Fields only:

    add_filter( 'meta_field_block_get_acf_field', function ( $block_content, $post_id, $field, $raw_value ) {
      $field_name = $field['name'] ?? '';
    
      if ( 'your_unique_field_name' === $field_name && $block_content !== '' ) {
        $block_content = sprintf('%2$s', get_permalink($post_id), $block_content);
      }
    
      return $block_content;
    }, 10, 4);
    

    This snippet only works with the block that has only HTML inline tags or an image.

  3. How to display an image URL field as an image tag?
    Using the meta_field_block_get_block_content hook:

    add_filter( 'meta_field_block_get_block_content', function ( $block_content, $attributes, $block, $post_id ) {
      $field_name = $attributes['fieldName'] ?? '';
    
      if ( 'your_image_url_field_name' === $field_name && wp_http_validate_url($block_content) ) {
        $block_content = sprintf('your_image_url_field_name', esc_attr($block_content));
      }
    
      return $block_content;
    }, 10, 4);
    

    Using the meta_field_block_get_acf_field hook for ACF Fields only:

    add_filter( 'meta_field_block_get_acf_field', function ( $block_content, $post_id, $field, $raw_value ) {
      $field_name = $field['name'] ?? '';
    
      if ( 'your_image_url_field_name' === $field_name && wp_http_validate_url($block_content) ) {
        $block_content = sprintf('your_image_url_field_name', esc_attr($block_content));
      }
    
      return $block_content;
    }, 10, 4);
    
  4. How to display multiple meta fields in a block?
    For example, we need to display the full name of a user from two meta fields first_name and last_name.

    add_filter( 'meta_field_block_get_block_content', function ( $block_content, $attributes, $block, $post_id ) {
      $field_name = $attributes['fieldName'] ?? '';
    
      if ( 'full_name' === $field_name ) {
        $first_name = get_post_meta( $post_id, 'first_name', true );
        $last_name  = get_post_meta( $post_id, 'last_name', true );
    
        // If the meta fields are ACF Fields. The code will be:
        // $first_name = get_field( 'first_name', $post_id );
        // $last_name  = get_field( 'last_name', $post_id );
    
        $block_content = trim("$first_name $last_name");
      }
    
      return $block_content;
    }, 10, 4);
    

    Choose the field type as dynamic and input the field name as full_name.

  5. How to display a setting field?
    For example, we need to display a setting field named footer_credit on the footer template part of the site.

    add_filter( 'meta_field_block_get_block_content', function ( $block_content, $attributes, $block, $post_id ) {
      $field_name = $attributes['fieldName'] ?? '';
    
      // Replace `footer_credit` with your unique name.
      if ( 'footer_credit' === $field_name ) {
        $block_content = get_option( 'footer_credit', '' );
    
        // If the field is an ACF Field. The code will be:
        // $block_content = get_field( 'footer_credit', 'option' );
      }
    
      return $block_content;
    }, 10, 4);
    
  6. How to use MFB as a placeholder to display any kind of content?

SAVE YOUR TIME WITH MFB PRO

To display simple data type fields for posts, terms, and users, you only need the free version of MFB. MFB Pro can save you 90% of development time when working with ACF, or Meta Box complex fields. It achieves this by transforming your ACF complex field types into container blocks, which work similarly to core container blocks. This eliminates the need for creating custom blocks or writing custom code for displaying complex fields.

Below are some video tutorials that demonstrate how MFB Pro can help you display complex fields:

How to build a post template to display dynamic data without coding

How to display ACF Repeater fields as a list, grid, or carousel

How to display ACF Gallery fields as a grid, masonry, or carousel

The main features of MFB PRO are:

If this plugin is useful for you, please do a quick review and rate it on WordPress.org to help us spread the word. I would very much appreciate it.

Please check out my other plugins if you’re interested:

  • Content Blocks Builder – This plugin turns the Block Editor into a powerful page builder by allowing you to create blocks, variations, and patterns directly in the Block Editor without needing a code editor.
  • SVG Block – A block to display SVG images as blocks. Useful for images, icons, dividers, and buttons. It allows you to upload SVG images and load them into the icon library.
  • Icon separator – A tiny block just like the core/separator block but with the ability to add an icon.
  • Breadcrumb Block – A simple breadcrumb trail block that supports JSON-LD structured data and is compatible with WooCommerce.
  • Block Enhancements – Adds practical features to blocks like icons, box shadows, transforms, etc.
  • Counting Number Block – A block to display numbers with a counting effect
  • Better YouTube Embed Block – A block to solve the performance issue with embedded YouTube videos. It can also embed multiple videos and playlists.

The plugin is built using @wordpress/create-block.
MFB is developed using only native Gutenberg features to keep it fast and lightweight.
MFB Pro uses SwiperJS for the carousel layout. However, if you don’t use the carousel layout, …

DomainExposuresHeadersLast Checked
a*a*e*i*d*s*i*n*e*n*e*.fr βœ… F 2026-05-25 15:47:39
s*o*.h*d*.com (WP 6.9.4) βœ… F 2026-05-25 11:50:10
c*n*e*t*.at βœ… F 2026-05-25 11:04:32
a*e*l*n*d*v*l*p*e*t*.com βœ… F 2026-05-25 10:30:32
g*c*s*c.org (WP 7.0) βœ… F 2026-05-25 08:15:25
t*e*l*b.u*i*i.gr (WP 6.9.4) βœ… F 2026-05-25 05:36:51
h*r*o*y*e*t*l*r*s.com (WP 7.0) βœ… F 2026-05-25 04:52:58
v*e*e*i*i*u*e.fr βœ… D 2026-05-25 02:50:15
o*i*n*s*u*e*.com βœ… D 2026-05-24 22:57:23
c*d*l*w.com βœ… F 2026-05-24 21:30:57
c*a*t*r*u*z*e*i*.com βœ… F 2026-05-24 18:17:14
k*f*e*r*n*e.de (WP 7.0) βœ… F 2026-05-24 16:11:52
f*y*e*h*.com βœ… D 2026-05-24 15:46:00
c*n*a*n.org (WP 6.9.4) βœ… F 2026-05-24 15:12:18
t*r*s*x.com (WP 6.9.4) βœ… F 2026-05-24 14:09:43
t*r*s*c*s.com (WP 6.9.4) βœ… F 2026-05-24 14:09:43
t*r*s*c*.com (WP 6.9.4) βœ… F 2026-05-24 14:09:43
s*a*t*m*t*i*e*.com βœ… F 2026-05-24 12:06:51
o*d*s*u*e.com (WP 6.9.4) βœ… F 2026-05-24 11:55:48
f*s*i*a*d*f*l.be (WP 7.0) βœ… F 2026-05-24 10:31:54
a*u*t*n*a*x*i.com βœ… D 2026-05-24 10:03:09
m*r*u*y*a*p*o*.com (WP 7.0) βœ… F 2026-05-24 08:55:37
c*m*e*s*y*e.de (WP 6.9.4) βœ… C 2026-05-24 06:52:51
p*t*t*e*w*t*o*t*o*d*r*.com βœ… D 2026-05-24 05:29:06
s*r*u*-*t*d*o*.com βœ… F 2026-05-24 04:43:26
s*r*u*-*a*s.com βœ… F 2026-05-24 04:43:26
e*o*-*o*a*s*i.com βœ… D 2026-05-24 02:28:07
g*p*r*o*g*n*c*o*d.com (WP 6.9.4) βœ… B 2026-05-24 01:43:44
g*p*r*f*o*.com (WP 6.9.4) βœ… B 2026-05-24 01:43:44
l*d*a*j*.live βœ… D 2026-05-24 01:10:49
i*v*e*.i*a*i*e*r*a*i*e*g*n*y.nl (WP 7.0) βœ… F 2026-05-24 00:43:51
m*.w*a.org βœ… A 2026-05-23 20:20:55
q*i*c*i*s*.org βœ… F 2026-05-23 19:29:40
c*n*s*u*.de βœ… F 2026-05-23 18:54:39
t*e*n*o*a*i*n*o*p*n*.fr βœ… F 2026-05-23 18:18:30
s*o*t*b*s*n*s*i*a*r*c*.com (WP 7.0) βœ… F 2026-05-23 18:06:30
c*n*e*t*.de βœ… F 2026-05-23 17:07:45
t*r*t*e*i*e.com (WP 6.9.4) βœ… F 2026-05-23 13:29:34
p*a*z*.cz βœ… F 2026-05-23 10:24:20
l*g*f*r*h*b*i*d.com βœ… F 2026-05-23 10:12:47
k*n*o*n*w*e*i*.com βœ… F 2026-05-23 10:07:29
a*e*c*s*9.fr (WP 7.0) βœ… F 2026-05-23 09:50:13
v*a*o*b*s*o.org (WP 7.0) βœ… F 2026-05-23 09:16:25
p*f*i*t*e*o*n.com βœ… D 2026-05-23 08:00:24
p*f*i*i*a*.com βœ… D 2026-05-23 08:00:23
p*f*s*f*.com βœ… D 2026-05-23 08:00:23
p*f*l*n*o*.com βœ… D 2026-05-23 08:00:22
p*f*l*t*l*j*h*.com βœ… D 2026-05-23 08:00:22
p*f*l.com βœ… D 2026-05-23 08:00:22
p*f*i.com βœ… D 2026-05-23 08:00:22
m*n*v*g*t*r.org βœ… F 2026-05-23 06:05:49
d*e*d*v*w*.com (WP 7.0) βœ… F 2026-05-23 05:39:33
r*d*.com (WP 6.9.4) βœ… D 2026-05-23 04:48:53
s*l*.no (WP 7.0) βœ… F 2026-05-23 04:48:08
o*c*m*.site (WP 7.0) βœ… F 2026-05-22 23:41:21
k*w*i*e*a*d*.com βœ… B 2026-05-22 22:26:35
o*l*o*h*r*e*.com βœ… F 2026-05-22 19:35:55
n*d*l*d*n*o*.cz βœ… F 2026-05-22 18:40:35
a*t*m.no βœ… F 2026-05-22 15:17:23
c*m*e*s*y*e.it (WP 6.9.4) βœ… D 2026-05-22 14:55:12
c*m*e*-*t*l*.pl (WP 6.9.4) βœ… D 2026-05-22 14:55:11
c*m*e*s*y*e.tr (WP 6.9.4) βœ… D 2026-05-22 14:55:11
c*m*e*s*y*e.fr (WP 6.9.4) βœ… D 2026-05-22 14:55:11
c*m*e*-*t*l*.nl (WP 6.9.4) βœ… D 2026-05-22 14:55:11
c*m*e*s*y*e.es (WP 6.9.4) βœ… D 2026-05-22 14:55:11
i*s*g*t*n*o*m.c*.uk (WP 6.9.4) βœ… F 2026-05-22 13:59:04
r*p*n*o*i*t*.com βœ… C 2026-05-22 11:56:25
c*e*i*.se βœ… C 2026-05-22 10:51:11
g*e*e*-*e*l*g.de (WP 6.9.4) βœ… F 2026-05-22 10:45:01
d*a*s*i*.com (WP 6.9.4) βœ… F 2026-05-22 09:37:24
f*t*r*s*m*h*n*.org (WP 7.0) βœ… F 2026-05-22 09:33:07
t*e*i*c*.no βœ… F 2026-05-22 09:21:04
a*z*n*a*u.com (WP 7.0) βœ… F 2026-05-22 08:17:24
c*n*e*t*.ch βœ… F 2026-05-22 07:53:59
y*t*a*s*o*t*t*o*.org βœ… F 2026-05-22 07:33:16
o*i*n.com (WP 7.0) βœ… F 2026-05-22 06:06:51
k*o*s*l*s.com βœ… F 2026-05-22 04:34:41
c*-*i*l*g*s*o*e*.fr βœ… A 2026-05-22 04:00:08
y*r*t*n*.b*u.edu (WP 7.0) βœ… C 2026-05-22 00:10:07
w*h*m*b*l*i*s*n.de (WP 6.9.4) βœ… C 2026-05-21 20:27:32
e*o*l*u.com (WP 7.0) βœ… F 2026-05-21 18:58:09
l*m*l*o*.de (WP 6.9.4) βœ… F 2026-05-21 17:02:50
i*t*r*m.fr βœ… D 2026-05-21 15:17:14
m*l*t*n*n*w*.com (WP 6.9.4) βœ… F 2026-05-21 15:09:42
t*u*t*r*r*g.com (WP 6.9.4) βœ… F 2026-05-21 05:04:56
e*p*s*n*t*e*l*u*i*n.com (WP 7.0) βœ… F 2026-05-21 04:08:45
b*i*d*n*s*a*t*v*r*a*.de (WP 6.9.4) βœ… D 2026-05-21 04:01:57
e*e*t*.d*r*e*a*a*e*i.com (WP 6.9.4) βœ… F 2026-05-21 01:46:24
d*v*p*c*n*r*v*l*e*o*r*.com βœ… A 2026-05-20 23:04:53
o*a*i*.com βœ… A 2026-05-20 21:06:20
r*c*u*t.e*o*w*t*.com (WP 6.9.4) βœ… F 2026-05-20 19:36:56
s*m*w*a*s*l*d.com (WP 6.9.4) βœ… F 2026-05-20 19:27:18
d*t*i*c*o*l.com (WP 6.9.4) βœ… F 2026-05-20 17:13:27
e*x*o*a*t*.com βœ… A 2026-05-20 12:49:32
p*r*a*.f*e*.g*b.mx βœ… A 2026-05-20 12:09:46
o*f*n.com (WP 6.9.4) βœ… F 2026-05-20 09:49:41
1*a*t*o*h.com (WP 6.9.4) βœ… F 2026-05-20 06:44:39
t*i*l*d*i*d*i*e.com βœ… F 2026-05-20 02:21:59
a*t*m*b*l*e*z*.ru (WP 6.9.4) βœ… D 2026-05-20 01:38:08
o*i*i*l*y*-*i*e*-*i*i*n*.ru (WP 6.9.4) βœ… D 2026-05-20 01:38:07

Top 50 Plugins

Plugin Count
elementor 1,868,053
contact-form-7 1,839,138
elementor-pro 1,086,956
woocommerce 843,096
revslider 638,354
jetpack 478,746
js_composer 447,519
wp-rocket 347,732
essential-addons-for-elementor-lite 308,278
gravityforms 300,257
complianz-gdpr 269,093
cookie-law-info 241,775
instagram-feed 235,701
google-site-kit 229,472
sitepress-multilingual-cms 229,144
google-analytics-for-wordpress 220,437
elementskit-lite 217,876
header-footer-elementor 217,110
bluehost-wordpress-plugin 192,383
gutenberg 166,413
gutenberg-core 165,241
cookie-notice 160,147
litespeed-cache 140,996
the-events-calendar 137,971
wpforms-lite 133,159
gtranslate 132,650
astra-sites 122,378
popup-maker 119,986
tablepress 115,666
woocommerce-payments 115,555
coblocks 103,081
honeypot 101,592
astra-addon 98,381
duracelltomi-google-tag-manager 97,229
wp-smushit 96,743
all-in-one-seo-pack 96,258
LayerSlider 94,649
bb-plugin 92,877
megamenu 90,546
premium-addons-for-elementor 89,861
akismet 88,120
mailchimp-for-wp 86,426
cleantalk-spam-protect 85,881
woocommerce-gateway-stripe 85,506
ml-slider 84,529
borlabs-cookie 83,528
wp-pagenavi 82,783
fusion-builder 82,411
ewww-image-optimizer 81,669
smart-slider-3 80,822

Top 50 Themes

Theme Count
hello-elementor 638,947
Divi 528,350
astra 437,220
flatsome 147,608
generatepress 130,535
Avada 128,533
pub 113,783
twentytwentyfour 87,839
oceanwp 86,469
kadence 82,000
sydney 75,827
enfold 74,519
salient 68,746
twentyseventeen 58,508
h4 58,354
bb-theme 56,485
betheme 53,931
blocksy 53,040
cocoon-master 52,732
dt-the7 47,785
twentytwentyfive 46,005
neve 41,043
Avada-Child-Theme 38,823
woodmart 34,431
gox 34,352
bridge 33,904
twentytwentyone 33,206
lightning 32,337
twentytwenty 31,198
swell 29,067
voxel 27,638
Impreza 27,599
bricks 26,946
twentytwentythree 24,833
Newspaper 24,711
sinatra 24,616
kubio 22,257
twentytwentytwo 20,450
uncode 19,869
epik-redesign 19,288
twentysixteen 19,161
storefront 18,527
pro 18,211
Total 15,275
extendable 15,037
yith-wonder 14,135
hello-theme-child-master 13,902
yootheme 13,495
themify-ultra 13,469
hestia 13,422