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.
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:
- Meta Box plugin (or Meta Box Framework)
- Meta Box Group
- Meta Box Conditional Logic
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.
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).
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.
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.
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.
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.
Do the same thing for the remaining sub-groups, but remember to change the "value" in the last step.


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:
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
- Create A Dynamic Landing Page in WordPress Using Custom Field
- Create a Filter to Find Hotels by Location
- Create an OTA Website Like Booking.com with Meta Box Plugin - P1: Create a Page to Introduce Hotel Rooms
- Create an OTA Website Like Booking.com with Meta Box Plugin - P2: Create Filters on the Archive Page
- Create an OTA Website Like Booking.com with Meta Box Plugin - P3: Create Filters for Single Hotel Pages
- Create Dynamic Favicon in WordPress using Meta Box plugin
- Create Posts Series in WordPress Using Meta Box
- Display a User List On the Frontend with Meta Box
- Display The Latest Products Section - P2 - Using Meta Box and Elementor
- Display The Latest Products Section - P3 - Using Meta Box And Oxygen
- How to Add Custom Fields to Display Banners using Meta Box Plugin
- How to Add Guest Author in WordPress using Meta Box (Part 1)
- How to Add Guest Author in WordPress using Meta Box (Part 2)
- How to Add Related Posts to WordPress Using Meta Box
- How to Build a Hotel Booking Website Using Meta Box - P1
- How to Build a Hotel Booking Website Using Meta Box - P2 - Booking Page in Backend
- How to Build a Hotel Booking Website Using Meta Box - P4 - Booking Management Page
- How to Build a Hotel Booking Website Using Meta Box – P3 – Booking Page for Customer
- How to Create a Classified Ads Website using Meta Box
- How to Create a Product Page - P2 - Using Meta Box and Oxygen
- How to Create a Product Page - P3 - Using Meta Box and Bricks
- How to Create a Product Page - P4 - Using Meta Box and Elementor
- How to Create a Product Page - P5 - Using Meta Box and Gutenberg
- How to Create a Product Page - P6 -Using Meta Box and Breakdance
- How to Create a Product Page using Meta Box Plugin
- How to Create a Recipe - P2 - Using Meta Box and Oxygen
- How to Create a Recipe - P3 - Using Meta Box and Elementor
- How to Create a Recipe - P4 - Using Meta Box and Bricks
- How to Create a Recipe - P5 - Using Meta Box and Zion
- How to Create a Recipe - P6 - Using Meta Box and Brizy
- How to Create a Recipe - P7 - Using Meta Box and Breakdance
- How to Create a Recipe with Meta Box Plugin
- How to Create a Simple Listing - P2 - Using Meta Box and Bricks
- How to Create a Team Members Page - P1- Using Meta Box and Elementor
- How to Create a Team Members Page - P2 - Using Meta Box and Oxygen
- How to Create a Team Members Page - P3 - Using Meta Box and Bricks
- How to Create a Team Members Page - P4 - Just Meta Box
- How to Create a Team Members Page - P6 - using Meta Box and Breakdance
- How to Create a Video Gallery Page - P2 - Using Meta Box + Bricks
- How to Create a Video Gallery Page - P3 - Using Meta Box and Breakdance
- How to Create a Video Gallery Page Using Meta Box + Oxygen
- How to Create ACF Flexible Content Field with Meta Box
- How to Create an Auto-Updated Cheat Sheet in WordPress
- How to Create an FAQs Page - P1 - Using Meta Box and Elementor
- How to create an FAQs page - P2 - Using Meta Box and Oxygen
- How to create an FAQs page - P4 - Using Meta Box and Bricks
- How to Create an FAQs Page -P3- Using Meta Box
- How to Create Buttons with Dynamic Link using Custom Fields
- How to Create Category Thumbnails & Featured Images Using Custom Fields
- How to Create Download Buttons Using Custom Fields with Meta Box Plugin
- How to Create Menus for Restaurants - P1 - Using Meta Box and Elementor
- How to Create Menus for Restaurants - P2- Using Meta Box and Bricks
- How to Create Online Admission Form for School or University
- How to Create Online Reservation Form for Restaurants using Meta Box
- How to Create Relationships - P1 - Using Meta Box and Oxygen
- How to Create Taxonomy Thumbnails & Featured Images - P2 - Using Meta Box and Oxygen
- How to Display Images from Cloneable Fields - P1 - with Gutenberg
- How to Display Images from Cloneable Fields - P2 - with Oxygen
- How to Display Images from Cloneable Fields - P3 - with Elementor
- How to Display Images from Cloneable Fields - P4 - with Bricks
- How to Display Opening Hours for Restaurants - P1 - Using Meta Box + Gutenberg
- How to Display Opening Hours for Restaurants - P2 - Using Meta Box and Oxygen
- How to Display Product Variations - P1 - Using Meta Box and Gutenberg
- How to Display Product Variations - P2 - Using Meta Box and Oxygen
- How to Display Product Variations - P3 - Using Meta Box and Bricks
- How to Display The Latest Products - P5 - Using Meta Box and Bricks
- How to Display the Latest Products - P6 - using Meta Box and Breakdance
- How to Display the Latest Products Section - P4 - Using Meta Box + Zion
- How to Display the Most Viewed Posts - P1 - using MB Views
- How to Display the Most Viewed Posts - P2 - using Meta Box and Oxygen
- How to Filter Posts by Custom Fields - P2 - using Meta Box and FacetWP
- How to Manually Reorder Posts with Meta Box
- How to Show Featured Restaurants on Homepage - P1 - Meta Box + Elementor + WP Grid Builder
- How to Show Posts With a Specific Criteria - P3 - Using MB Views
- How to Show Posts with Specific Criteria - P1 - Using Meta Box and Bricks
- How to Show Posts with Specific Criteria - P2 - Using Meta Box and Oxygen
- How to Show the Featured Restaurants - P3 - using Meta Box and Oxygen
- How to Show the Featured Restaurants - P4 - Using MB Views
- How to Show the Featured Restaurants Section - P2 - Using Meta Box and Bricks
- How to Use Custom HTML Field to Output Beautiful Texts or Output Custom CSS