I guess that you have heard or even used the Flexible Content Field from Advanced Custom Fields (ACF) plugin. Haven't you? If you are looking for ways to create it but don't want to use ACF, follow this post. I will guide you to create one kind of ACF Flexible Content Field, but using Meta Box plugin to do.

Because of using a tool that is not ACF, there are some definitions that are different from the ones called by ACF. We will find out each one below.

Let's make them clear.

What is Meta Box?

Meta Box is a simple yet powerful plugin that helps developers build custom meta boxes and custom fields in WordPress fast and easily.

We have published a very detailed post about Meta Box, how to use it, and what are its advantages. Please spend several minutes finding out here.

In this post, we also present 2 its extensions, which are the main tools to use in this tutorial, are Meta Box Group and Meta Box Conditional Logic.

Meta Box Group

Meta Box Group is an extension of Meta Box plugin. It allows you to group fields together, organize and rearrange them to have a visually stunning hierarchy. It also helps you to clone fields in an easy way, or make groups be collapsible.

This is a premium extension from Meta Box, so you need to pay for it. You may buy this plugin individually or buy a Meta Box's bundle of extensions which includes many helpful extensions and saves you money.

Meta Box Conditional Logic

Meta Box Conditional Logic, like Meta Box Group, is an extension of Meta Box. As said by its name, it allows you to assign a condition for any field to set when that field displays. This condition will base on the value of another field.

This is a premium extension of Meta Box, so you need to pay for it as well.

What is Flexible Content Field?

Flexible Content Field (ACF)

Flexible Content Field is a type of field supported by ACF. It allows you to create a layout including different sections and each one includes different sub-fields. Among the sections, you can clone anyone you want.

View this video to know more about what Flexible Content Field can do:

Group Field (Meta Box)

Meta Box plugin actually has no field which is equivalent to ACF Flexible Content Field. So that, to create that kind of field, I will use a field type named Group of Meta Box.

Meta Box Group Album example

In order to create this field, Group Field, we will use Meta Box Group.

This Group Field will help you group the fields together, create a sub-group, and clone its sub-field / sub-group as well. All features are available in the Flexible Content Field of ACF.

However, Group Field's nature does not include assigning a field that can be displayed based on another field's value (but Flexible Content Field of ACF has). Fortunately, Meta Box has another interesting extension named Meta Box Conditional Logic that can do it.

Whenever you combine Meta Box Group and Meta Box Conditional Logic, the Group Field will have all the features that Flexible Content Field of ACF has, even more. We will explore their abilities when combining them together in later posts.

Now, come back to creating fields.

How to create Flexible Content Field without ACF, but using Meta Box

Before getting started

We need to install and activate all the below plugins:

Remember to activate all of them.

In addition, if you want to create and configure the fields with a visual and intuitive interface and don't want to touch any code, you should use Meta Box Builder. I did it in this post.

Learn more about how to install and activate plugins here.

Get started to create Flexible Content Field

I will summarize the process for you to get the overall view.

Firstly, I will create a parent group, then a field in the select type and sub-groups inside the parent group. Secondly and also finally, I will assign a condition to the sub-groups to set when each one displays.

It is pretty easy, isn't it? Let's do it.

Step 1: Create a parent group

In the admin dashboard, go to Meta Box > Custom Fields > Add New. Then, click Add Field button (see the below image to know where it is) and select the Group field in the dropdown menu appearing right after that. A field in group type will appear.

Create group by Meta Box to make flexible content field

I set it to name "Sections" and tick the boxes "Cloneable" (which allows you to clone this group) and "Collapsible" (which allows you to collapse or expand this group).

configure the group by Meta Box to create flexible content field

Step 2: Create a Select Field insides the above parent group

Similar to the way of creating the parent group, just look for the Select field. But we will create a sub-field inside the group field above by clicking Add Field button inside the Sections field.

Create select field by Meta Box to create flexible content field

There is no need to configure this field now, just skip it and move on. We will configure it in the final step.

Step 3: Create sub-groups inside the parent group

I'm going to create 3 sub-groups, each one will be proportional to one option in the Select Field.

  • 1st sub-group - Services: we create an additional and cloneable sub-group inside this one. This section represents the services as said by its name, so it would be repeatable.
  • 2nd sub-group - Testimonials: we also create a sub-group insides this one.
  • 3rd sub-group - Facts: this sub-group will include a text field, a textarea field, and a sub-group as well.

In order to create these fields and sub-groups, just choose the Group field and click the Add Field button inside it.

fields structure created by Meta Box to create flexible content field

Step 4: Assign conditional logic to the fields/groups

Now, we will set up the conditions to sub-groups to be displayed only when the Select Field has a proportion value.

This is the final step and the most difficult one to express. Please take a look at the image for more explanation.

Back to the Select Field. In the configuration area of this field, add options that are proportional to the name of sub-groups. In this tutorial, I added Services, Testimonials, and Facts as the name of my sub-groups.

Add options for Select field of Meta Box

Then, go to the group named "Services", choose the Advanced tab, then Conditional Logic and start to add a condition by clicking Add Rule.

I will set up it as below:

  • Choose Visible when All of these conditions match. Choosing "All" or "Any" have no meaning in this case because we are going to enclose only 1 condition.
  • Enter the condition values. In there:
    • select: the ID of the Select Field;
    • Value: is one of option we added in the Select Field. It is the value when you want the sub-group (which you are setting for) to be displayed.

Set condition for a group of custom fields

Do the same thing for the remaining sub-groups, but remember to change the "value" in the last step.

Set condition for the Testimonials sub-group
Set condition for the Testimonials sub-group
Set condition for the Facts sub-group
Set condition for the Facts sub-group

Now, we have done. Just press "Save" now.

Result

After saving the custom fields and groups, now edit a page. If nothing goes wrong, you'll see the result like this:

Create ACF Flexible Content Field with Meta Box Group

As you see, it's very similar to ACF Flexible Content Field. You can add a section for your content, select what type of section and fill in all the fields that section might have.

Create Flexible Content Field with Code

If you don't use Meta Box Builder to create fields and groups visually, you can always do that with code. Below is the code for all the above set up. Just copy and paste it into your functions.php file of your theme and you're done!



This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters


<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Flexible Field Example',
'post_types' => 'page',
'fields' => array(
array (
'id' => 'sections',
'type' => 'group',
'name' => 'Sections',
'fields' => array(
array (
'id' => 'select',
'name' => 'Select',
'type' => 'select',
'placeholder' => 'Select an Item',
'options' => array(
'Services' => 'Services',
'Testimonials' => 'Testimonials',
'Facts' => 'Facts',
),
),
array (
'id' => 'services',
'type' => 'group',
'name' => 'Services',
'fields' => array(
array (
'id' => 'secvices_box',
'type' => 'group',
'name' => 'Secvices Box',
'fields' => array(
array (
'id' => 'image',
'type' => 'single_image',
'name' => 'Icon services',
'desc' => 'Transparent background',
),
array (
'id' => 'description',
'type' => 'textarea',
'name' => 'Description',
),
),
'clone' => true,
'collapsible' => true,
'group_title' => 'Secvices Box',
),
),
'default_state' => 'expanded',
'collapsible' => true,
'save_state' => true,
'group_title' => 'Services Section',
'visible' => array( 'select', 'Services' ),
),
array (
'id' => 'testimonials',
'type' => 'group',
'name' => 'Testimonials',
'fields' => array(
array (
'id' => 'testimonials_box',
'type' => 'group',
'name' => 'Testimonials Box',
'fields' => array(
array (
'id' => 'image_upload_2',
'type' => 'image_upload',
'name' => 'Image profile',
'max_status' => false,
'max_file_uploads' => 1,
'image_size' => 'thumbnail',
),
array (
'id' => 'Content',
'name' => 'Content',
'type' => 'wysiwyg',
),
),
),
),
'collapsible' => true,
'group_title' => 'Testimonials Section',
'visible' => array( 'select', 'Testimonials' ),
),
array (
'id' => 'facts',
'type' => 'group',
'name' => 'Facts',
'fields' => array(
array (
'id' => 'title',
'type' => 'text',
'name' => 'Title Fact',
),
array (
'id' => 'textarea_2',
'type' => 'textarea',
'name' => 'Description Fact',
),
array (
'id' => 'group_2',
'type' => 'group',
'name' => 'Fact Box',
'fields' => array(
array (
'id' => 'text_2',
'type' => 'text',
'name' => 'Title',
),
array (
'id' => 'number_2',
'type' => 'number',
'name' => 'Amount',
),
),
),
),
'collapsible' => true,
'group_title' => 'Facts Section',
'visible' => array( 'select', 'Facts' ),
),
),
'clone' => true,
'collapsible' => true,
'save_state' => true,
'group_title' => 'Choose which section you want',
),
),
);
return $meta_boxes;
}

Final words

Flexible Content Field is a very interesting feature from the PRO version of the Advanced Custom Fields plugin. It allows you to build groups with different sub-fields based on their type. In this tutorial, I've guided you to achieve the same thing using Meta Box's extensions. You might want to explore more features of Meta Box Group, Meta Box Conditional Logic to see what they are capable of. And if you have any comments, please let us know below.

Other case studies you might be interested in

  1. Create A Dynamic Landing Page in WordPress Using Custom Field
  2. Create a Filter to Find Hotels by Location
  3. Create an OTA Website Like Booking.com with Meta Box Plugin - P1: Create a Page to Introduce Hotel Rooms
  4. Create an OTA Website Like Booking.com with Meta Box Plugin - P2: Create Filters on the Archive Page
  5. Create an OTA Website Like Booking.com with Meta Box Plugin - P3: Create Filters for Single Hotel Pages
  6. Create Dynamic Favicon in WordPress using Meta Box plugin
  7. Create Posts Series in WordPress Using Meta Box
  8. Display The Latest Products Section - P2 - Using Meta Box and Elementor
  9. Display The Latest Products Section - P3 - Using Meta Box And Oxygen
  10. How to Add Custom Fields for WooCommerce - P2 - Using MB Views
  11. How to Add Custom Fields to Display Banners using Meta Box Plugin
  12. How to Add Guest Authors and Guest Posts - Using Meta Box
  13. How to Add Related Posts - Using Custom Fields
  14. How to Build a Hotel Booking Website Using Meta Box - P1
  15. How to Build a Hotel Booking Website Using Meta Box - P2 - Booking Page in Backend
  16. How to Build a Hotel Booking Website Using Meta Box - P4 - Booking Management Page
  17. How to Build a Hotel Booking Website Using Meta Box – P3 – Booking Page for Customer
  18. How to Create a Classified Ads Website using Meta Box
  19. How to create a FAQs page - P5 - Using Meta Box and Breakdance
  20. How to Create a Product Page - P2 - Using Meta Box and Oxygen
  21. How to Create a Product Page - P3 - Using Meta Box and Bricks
  22. How to Create a Product Page - P4 - Using Meta Box and Elementor
  23. How to Create a Product Page - P5 - Using Meta Box and Gutenberg
  24. How to Create a Product Page - P6 -Using Meta Box and Breakdance
  25. How to Create a Product Page - P7 - Using Meta Box + Kadence
  26. How to Create a Product Page - P8 - Using Meta Box and Brizy
  27. How to Create a Product Page - P9 - Using Meta Box and Divi
  28. How to Create a Product Page using Meta Box Plugin
  29. How to Create a Recipe - P2 - Using Meta Box and Oxygen
  30. How to Create a Recipe - P3 - Using Meta Box and Elementor
  31. How to Create a Recipe - P4 - Using Meta Box and Bricks
  32. How to Create a Recipe - P5 - Using Meta Box and Zion
  33. How to Create a Recipe - P6 - Using Meta Box and Brizy
  34. How to Create a Recipe - P7 - Using Meta Box and Breakdance
  35. How to Create a Recipe - P8 - Using Meta Box and Kadence
  36. How to Create a Recipe - P9 - Using Meta Box and Divi
  37. How to Create a Recipe with Meta Box Plugin
  38. How to Create a Simple Listing - P2 - Using Meta Box and Bricks
  39. How to Create a Simple Listing - P3 - Using Meta Box and Breakdance
  40. How to Create a Simple Listing - P4 - Using Meta Box and Elementor
  41. How to Create a Team Members Page - P1- Using Meta Box and Elementor
  42. How to Create a Team Members Page - P2 - Using Meta Box and Oxygen
  43. How to Create a Team Members Page - P3 - Using Meta Box and Bricks
  44. How to Create a Team Members Page - P4 - Just Meta Box
  45. How to Create a Team Members Page - P6 - using Meta Box and Breakdance
  46. How to Create a Team Members Page - P7 - Using Meta Box and Kadence
  47. How to Create a Video Gallery Page - P2 - Using Meta Box + Bricks
  48. How to Create a Video Gallery Page - P3 - Using Meta Box and Breakdance
  49. How to Create a Video Gallery Page - P4 - Using Meta Box + Elementor
  50. How to Create a Video Gallery Page - P5 - Using MB Views
  51. How to Create a Video Gallery Page - P6 - Using Meta Box and Zion
  52. How to Create a Video Gallery Page Using Meta Box + Oxygen
  53. How to Create ACF Flexible Content Field with Meta Box
  54. How to Create an Auto-Updated Cheat Sheet in WordPress
  55. How to Create an FAQs Page - P1 - Using Meta Box and Elementor
  56. How to create an FAQs page - P2 - Using Meta Box and Oxygen
  57. How to create an FAQs page - P4 - Using Meta Box and Bricks
  58. How to Create an FAQs Page - P6 - Using MB Views
  59. How to Create an FAQs Page - P7 - Using Meta Box and Divi
  60. How to Create an FAQs Page - P8 - Using Meta Box and Kadence
  61. How to Create an FAQs Page -P3- Using Meta Box
  62. How to Create Buttons with Dynamic Link using Custom Fields
  63. How to Create Category Thumbnails & Featured Images Using Custom Fields
  64. How to Create Download and Preview Buttons - P1 - Using Meta Box and Bricks
  65. How to Create Download and Preview Buttons - P2 - Using Meta Box and Oxygen
  66. How to Create Download and Preview Buttons - P3 - Using MB Views
  67. How to Create Download Buttons in WordPress - Using Custom Fields
  68. How to Create Dynamic Landing Page in WordPress - P1 - Using Meta Box and Elementor
  69. How to Create Dynamic Landing Page in WordPress - P2 - Using Meta Box and Bricks
  70. How to Create Menus for Restaurants - P1 - Using Meta Box and Elementor
  71. How to Create Menus for Restaurants - P2- Using Meta Box and Bricks
  72. How to Create Notification Using Custom HTML Field
  73. How to Create Online Admission Form for School or University
  74. How to Create Online Reservation Form for Restaurants using Meta Box
  75. How to Create Relationships - P1 - Using Meta Box and Oxygen
  76. How to Create Relationships - P2 - Using Meta Box and Bricks
  77. How to Create Relationships - P3 - Using MB Views
  78. How to Create Relationships - P4 - Using Meta Box and Breakdance
  79. How to Create Taxonomy Thumbnails & Featured Images - P2 - Using Meta Box and Oxygen
  80. How to Create Taxonomy Thumbnails & Featured Images - P3 - Using Meta Box and Bricks
  81. How to Create Taxonomy Thumbnails & Featured Images - P4 - Using MB Views
  82. How to Create YouTube Video Timestamps on WordPress Website - P1 - Using MB Views
  83. How To Display All Listings On A Map With Meta Box
  84. How to Display Author Bio in WordPress - P1 - Using Meta Box and Bricks
  85. How to Display Images from Cloneable Fields - P1 - with Gutenberg
  86. How to Display Images from Cloneable Fields - P2 - Using Meta Box and Oxygen
  87. How to Display Images from Cloneable Fields - P3 - with Elementor
  88. How to Display Images from Cloneable Fields - P4 - with Bricks
  89. How to Display Opening Hours for Restaurants - P1 - Using Meta Box + Gutenberg
  90. How to Display Opening Hours for Restaurants - P2 - Using Meta Box and Oxygen
  91. How to Display Product Variations - P1 - Using Meta Box and Gutenberg
  92. How to Display Product Variations - P2 - Using Meta Box and Oxygen
  93. How to Display Product Variations - P3 - Using Meta Box and Bricks
  94. How to Display the Dynamic Banners - P2 - Using Meta Box and Bricks
  95. How to Display The Latest Products - P5 - Using Meta Box and Bricks
  96. How to Display the Latest Products - P6 - using Meta Box and Breakdance
  97. How to Display the Latest Products - P7 - Using Meta Box + Kadence
  98. How to Display the Latest Products Section - P4 - Using Meta Box + Zion
  99. How to Display the Most Viewed Posts - P1 - using MB Views

Leave a Reply

Your email address will not be published. Required fields are marked *