Skip to main content

Creating a recipe - Meta Box + Divi

Have you tried MB Divi Integrator? Continuing the Create a Recipe page series, today we will figure out the way to create an impressive, eye-catching recipe using Meta Box and Divi Builder with the help of their integration.

I created a singular page containing the recipe information as an example:

a singular page containing the recipe information as an example

Video version

Preparation

Each recipe will be saved in a post of a custom post type. The recipe's name and dish picture are the post's title and featured image. Besides, you may want to have more space for the extra information. They will be saved in custom fields and separated into different sections for easier styling and managing.

So, the necessary tools are listed below:

  • Meta Box core plugin: to have the framework for creating the custom post type and custom fields;
  • MB Custom Post Type: to create a custom post type for the recipes;
  • Meta Box Builder: to have a UI on the back end to easily create custom fields;
  • MB Divi Integrator: allows Divi to get data from custom fields created with Meta Box easier. This is the must-have one;
  • Divi Builder to build the page.

1. Creating a custom post type

Go to Meta Box > Post Types > Add New to create a new one for the recipes.

Go to Meta Box, Post Types, Add New to create a new one for the recipes

After publishing, you will see a new menu displayed. It's your post type.

created post type displayed as a menu in admin dashboard

2. Creating custom fields

Go to Meta Box > Custom Fields to create fields to save the recipe information you want.

Go to Meta Box, Custom Fields to create fields to save the recipe information you want

These are the fields that I created:

some fields were created as example

There is a field for video that is quite special. If you want to display the video preview on the frontend, I highly recommend you use the oEmbed field for the video instead of the URL field.

to display the video preview on the frontend, use the oEmbed field for the video instead of the URL field

Before publishing, move to the Settings tab, set the Location as Post Type, and select Recipe to apply these fields to it.

move to the Settings tab, set the Location as Post Type, and select Recipe to apply these fields to it

Then, in the post editor of the Recipe post type, you will see created custom fields.

created fields in post editor of the Recipe post type

Just input data.

3. Creating template for the page

To display each recipe on each page, we should create a template for their singular page.

Go to Divi > Theme Builder to create a new template.

Go to Divi, Theme Builder to create a new template for the singular page of each recipe

To apply this template for recipes, choose All Recipes in the Template Settings popup.

choose All Recipes in the Template Settings popup to apply this template for recipes

Add a row for the first line on the page.

Add a row for the first line on the page

It’s the post title, so search the Post Title module.

It’s the post title, so search the Post Title module

For this first section, add a new row. You can choose any layout as you want for this section.

For this first section, add a new row and choose any layout as you want for this section

In the first column, add the Image module.

In the first column, add the Image module

Then click on the Dynamic Content icon button.

click on the Dynamic Content icon button

And choose the Featured Image from the dropdown list.

choose the Featured Image from the dropdown list

the image will display like this

Move to the second column, I will display the timing information.

They’re all text, so add the Text module.

add the Text module for the timing information

We also use the Dynamic Content icon button to get data from custom fields.

also use the Dynamic Content icon button to get data from custom fields

Since the information is saved in custom fields from Meta Box, find the Meta Box: Recipe Information section, and select the custom field you want.

Since the information is saved in custom fields from Meta Box, find the Meta Box: Recipe Information section, and select the custom field you want

You can add the After text to have a clearer name the information on the page.

You can add the After text to have a clearer name the information on the page

The next three information also are the timing ones, and may have the same style with the first one. So duplicate the Text module.

duplicate the Text module for the next three information

Then use the dynamic content feature to change and get data from the corresponding field.

use the dynamic content feature to change and get data from the corresponding field

Also rename the after text.

rename the after text

The timing information was gotton

Add a new Row for the next section.

Add a new Row for the next section

Choose the Text module for the name of the section.

hoose the Text module for the name of the section

The ingredients information in this section is saved in a custom field created with Meta Box. But it’s not normal text. It may include some format since the WYSIWYG field. So, instead of using the Text module from Divi as previously, we should use the Meta Box Field module.

we should use the Meta Box Field module to get the data from the WYSIWYG field instead of using the Text module from Divi as previously

This is the module built by the Meta Box team that has more advantages and more optimality, especially it can display the text in the right format as you save in the custom field.

Just set the location for this module as the field you want.

Click on the location to set location for the module

choose the field in the dropdown list

The data will display on the frontend later.

For the next type of information, we also add a couple of modules, one for the title, and one for the data.

The Text module for the name of section.

add a Text module for the name of instructions section

However, the instructions section may include information which are set in steps. I saved them in a cloneable group, so instead of adding a Meta Box Field module, we should add a layout for this group first.

Go to Divi > Divi Library > Add New to create a new layout.

Go to Divi, Divi Library, Add New to create a new layout for the group

Set the Layout Type as Section.

Set the Layout Type as Section

Inside the layout, add the Meta Box Field module.

Inside the layout, add the Meta Box Field module

And set its location as a subfield of the group to get data from it.

set its location as a subfield of the group to get data from it

since we have 2 subfields in the group, we need to use 2 Meta Box Field modules

Now, back to the page template editor, and add the Meta Box Cloneable module.

back to the page template editor, and add the Meta Box Cloneable module

Set its layout as the one we have just created.

Set its layout as the one we have just created

Also set the Cloneable Field as the group.

set the Cloneable Field as the group

All the information of each step will be listed on the page when you go to the page on front end.

For the next, add the Text module for the title as well.

For the next, add the Text module for the title

For the data from custom fields, if it’s not a cloneable one, we highly recommend using the Meta Box Field module. No matter which kind of data you want to get, even with the video URL, just use this module.

we highly recommend using the Meta Box Field module because it can get every kind of data even with the video URL

Every information is gotton

After getting all of the information, view the page on the frontend, all the information is displayed, and their format is also as they are in the custom fields.

on the frontend, all the information is displayed with the right format

Let’s move one to make them display better.

4. Styling the page

Back to the page template editor, just choose each module to change their settings, one by one.

To style the page, back to the page template editor, choose each module to change their settings, one by one

I just changed some things basically.

And this is the final look of the page.

the final look of the page

You definitely can change the template’s layout to have a more efficient display since all the information is now from custom fields, so you can rearrange or set places for them very easily.