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

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

Meta Field Block

πŸ‘€ Phi Phan πŸ”— 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
t*e*e*h*h*p*e*s.com F Jul 24, 2026
e*r*z*a*t*e*s.com (WP 7.0.2) F Jul 24, 2026
c*b*r*t*l*n*o*i*e.com F Jul 24, 2026
c*i*a*t.fr (WP 7.0.2) F Jul 24, 2026
p*n*e*l*u*e*a*h*m*.com F Jul 24, 2026
p*n*a*l*s*g*a*u*e*i*h*i*g.com F Jul 23, 2026
f*n*n*e*n*f*i*a.com (WP 7.0.2) F Jul 23, 2026
s*e*a*s*u*i*-*7.com F Jul 23, 2026
k*n*a*i*i*c*i*a*i*n*r*i*i*g.com (WP 7.0.2) F Jul 23, 2026
s*i*7*.fr A Jul 23, 2026
r*o*s*n*m*p*.com (WP 7.0.2) D Jul 23, 2026
l*f*d*g*t*l.c*.uk A Jul 23, 2026
m*n*g*p.com (WP 6.9.4) F Jul 23, 2026
s*-*i*.se F Jul 23, 2026
d*r*y*a*i*a.com D Jul 23, 2026
j*c*b*w*l*c*u*c*.org F Jul 23, 2026
m*n*a*d*a*s.com B Jul 23, 2026
o*t*a*d*b*e*v*r.com (WP 7.0.2) F Jul 23, 2026
p*u*q*e*u*r*v*i*.ca C Jul 23, 2026
m*n*i*u*.com (WP 7.0) F Jul 23, 2026
l*s*s*i*a*k*n*o*i*a*s.com B Jul 23, 2026
d*m*r*a*a*f*t*n*.com (WP 7.0.2) F Jul 22, 2026
u*a*i*m*r*d*c*i*n*.com (WP 7.0.2) F Jul 22, 2026
s*g*b.org (WP 7.0.2) F Jul 22, 2026
m*a*o*v*l*e.com D Jul 22, 2026
s*a*t*h*s*o.com (WP 7.0.2) F Jul 22, 2026
m*j*p*.com (WP 7.0.2) F Jul 22, 2026
i*e*r*s*o*a*i*e*a*e.com F Jul 22, 2026
b*s*n*s*f*o*t.com (WP 7.0.2) F Jul 22, 2026
c*n*g*e*n.com (WP 6.9.5) F Jul 22, 2026
d*g*t*l*i*r*e*t*r*r*s*.com (WP 7.0.2) F Jul 22, 2026
s*t.ca F Jul 22, 2026
a*a*e*i*d*s*i*n*e*n*e*.fr F Jul 22, 2026
c*n*e*t*.at F Jul 21, 2026
a*e*l*n*d*v*l*p*e*t*.com F Jul 21, 2026
k*e*n*l*s*c*.com F Jul 21, 2026
g*c*s*c.org (WP 7.0.1) F Jul 21, 2026
e*o*l*u.fr (WP 7.0.2) F Jul 21, 2026
h*r*o*y*e*t*l*r*s.com (WP 7.0.2) F Jul 21, 2026
o*i*n*s*u*e*.com D Jul 21, 2026
c*a*t*r*u*z*e*i*.com F Jul 21, 2026
m*s*o*e*d*s*r*o*l*.es (WP 7.0.2) F Jul 21, 2026
f*y*e*h*.com D Jul 21, 2026
c*n*a*n.org (WP 6.9.5) F Jul 21, 2026
t*r*s*x.com (WP 6.9.5) F Jul 20, 2026
t*r*s*c*s.com (WP 6.9.5) F Jul 20, 2026
t*r*s*c*.com (WP 6.9.5) F Jul 20, 2026
s*a*t*m*t*i*e*.com F Jul 20, 2026
o*d*s*u*e.com (WP 7.0.2) F Jul 20, 2026
f*s*i*a*d*f*l.be (WP 7.0.2) F Jul 20, 2026
a*u*t*n*a*x*i.com D Jul 20, 2026
m*r*u*y*a*p*o*.com (WP 7.0.2) F Jul 20, 2026
c*m*e*s*y*e.de (WP 7.0.2) C Jul 20, 2026
p*t*t*e*w*t*o*t*o*d*r*.com D Jul 20, 2026
p*c*a*l*y.ru (WP 7.0.2) F Jul 20, 2026
s*r*u*-*t*d*o*.com F Jul 20, 2026
s*r*u*-*a*s.com F Jul 20, 2026
b*t*e*-*o*e.fr B Jul 20, 2026
e*o*-*o*a*s*i.com D Jul 20, 2026
g*p*r*o*g*n*c*o*d.com (WP 7.0.2) B Jul 20, 2026
g*p*r*f*o*.com (WP 7.0.2) B Jul 20, 2026
k*r*e.to D Jul 20, 2026
l*d*a*j*.live D Jul 20, 2026
q*i*c*i*s*.org F Jul 20, 2026
c*n*s*u*.de F Jul 20, 2026
c*n*e*t*.de F Jul 20, 2026
t*r*t*e*i*e.com (WP 7.0.2) F Jul 19, 2026
p*a*z*.cz F Jul 19, 2026
l*g*f*r*h*b*i*d.com F Jul 19, 2026
k*n*o*n*w*e*i*.com F Jul 19, 2026
a*e*c*s*9.fr (WP 7.0.2) F Jul 19, 2026
p*f*i*t*e*o*n.com D Jul 19, 2026
p*f*i*i*a*.com D Jul 19, 2026
p*f*s*f*.com D Jul 19, 2026
p*f*l*n*o*.com D Jul 19, 2026
p*f*l*t*l*j*h*.com D Jul 19, 2026
p*f*l.com D Jul 19, 2026
p*f*i.com D Jul 19, 2026
m*n*v*g*t*r.org F Jul 19, 2026
d*e*d*v*w*.com (WP 7.0.2) F Jul 19, 2026
r*d*.com (WP 7.0.2) D Jul 19, 2026
s*l*.no (WP 7.0.1) F Jul 19, 2026
k*w*i*e*a*d*.com B Jul 19, 2026
a*y*e*l*a*e*t.com B Jul 19, 2026
o*l*o*h*r*e*.com F Jul 19, 2026
n*d*l*d*n*o*.cz F Jul 19, 2026
c*m*e*s*y*e.it (WP 7.0.2) D Jul 18, 2026
c*m*e*-*t*l*.pl (WP 7.0.2) D Jul 18, 2026
c*m*e*s*y*e.tr (WP 7.0.2) D Jul 18, 2026
c*m*e*s*y*e.fr (WP 7.0.2) D Jul 18, 2026
c*m*e*-*t*l*.nl (WP 7.0.2) D Jul 18, 2026
c*m*e*s*y*e.es (WP 7.0.2) D Jul 18, 2026
r*p*n*o*i*t*.com C Jul 18, 2026
c*e*i*.se C Jul 18, 2026
g*e*e*-*e*l*g.de (WP 6.9.4) F Jul 18, 2026
d*a*s*i*.com (WP 7.0.2) F Jul 18, 2026
f*t*r*s*m*h*n*.org (WP 7.0.2) F Jul 18, 2026
t*e*i*c*.no F Jul 18, 2026
a*z*n*a*u.com (WP 7.0.2) F Jul 18, 2026
c*n*e*t*.ch F Jul 18, 2026

Top 50 Plugins

Plugin Count
elementor 1,769,947
contact-form-7 1,751,151
elementor-pro 1,052,329
woocommerce 816,084
revslider 608,676
jetpack 454,679
js_composer 419,902
wp-rocket 342,079
essential-addons-for-elementor-lite 264,695
gravityforms 257,300
complianz-gdpr 257,186
google-site-kit 232,602
cookie-law-info 228,240
instagram-feed 224,724
sitepress-multilingual-cms 210,596
header-footer-elementor 206,656
google-analytics-for-wordpress 205,675
bluehost-wordpress-plugin 192,331
elementskit-lite 180,017
gutenberg 167,120
cookie-notice 148,816
litespeed-cache 143,825
gtranslate 124,781
wpforms-lite 123,738
the-events-calendar 122,341
astra-sites 113,144
popup-maker 109,698
woocommerce-payments 109,299
gutenberg-core 103,141
tablepress 102,135
honeypot 97,728
astra-addon 93,740
wp-smushit 90,814
duracelltomi-google-tag-manager 90,306
layerslider 89,283
all-in-one-seo-pack 89,071
bb-plugin 86,901
coblocks 86,693
akismet 84,979
premium-addons-for-elementor 84,367
cleantalk-spam-protect 82,573
ml-slider 81,991
mailchimp-for-wp 81,773
megamenu 80,196
woocommerce-gateway-stripe 79,441
jet-engine 77,892
fusion-builder 77,057
ewww-image-optimizer 76,627
wp-pagenavi 76,457
smart-slider-3 76,121

Top 50 Themes

Theme Count
hello-elementor 620,749
Divi 496,071
astra 413,940
flatsome 138,152
Avada 120,987
generatepress 114,820
oceanwp 80,309
kadence 78,841
pub 72,283
enfold 68,738
salient 65,153
twentyseventeen 54,318
bb-theme 53,400
betheme 52,414
twentytwentyfour 52,234
blocksy 50,827
cocoon-master 49,206
dt-the7 45,445
twentytwentyfive 44,937
woodmart 43,254
neve 38,122
Avada-Child-Theme 36,904
gox 36,229
h4 36,037
bridge 31,326
twentytwentyone 30,291
lightning 29,946
twentytwenty 28,762
swell 27,969
bricks 26,481
Impreza 26,076
Newspaper 24,176
twentytwentythree 22,095
epik-redesign 19,143
twentytwentytwo 18,767
uncode 18,501
pro 17,626
twentysixteen 17,602
sydney 16,502
storefront 16,314
Total 14,390
hello-theme-child-master 14,021
factory-templates-4 13,731
themify-ultra 12,948
extendable 12,765
hestia 12,582
yootheme 12,515
yith-wonder 12,108
porto 11,949
twentyfifteen 11,874