How to Create a Recipe - P5 - Using Meta Box and Zion
Tags: tutorial, customfields, recipe, metabox
Published: 2022-11-15 01:56:35

Continuing with the series '<a href="https://metabox.io/series/recipe/">Create a recipe</a>', today we'll show you how to do it with another page builder, <strong>Zion</strong>.

<!--more-->

We also have a demo page for the tutorial like this:

<img class="aligncenter" src="https://i.imgur.com/v9WMsy5.png" alt="Demo page of a recipe page" width="600" height="917" />

<h2>Video Version</h2>

https://youtu.be/y6XCjCj3EZ8

<h2>Before Getting Started</h2>

Like in the previous parts, all of the recipe information 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. And, the extra information will be saved in custom fields.

Here are the tools that we need for this practice:

First, we need the <a href="https://wordpress.org/plugins/meta-box/">Meta Box core plugin</a> to have the framework for creating custom post types and custom fields. You can download it directly from <a href="https://wordpress.org/plugins/meta-box/">wordpress.org</a> as it's free.

To have the advanced features of Meta Box, we need some of its extensions:

<ul>

   <li><a href="https://metabox.io/plugins/custom-post-type/">MB Custom Post Types &amp; Custom Taxonomies:</a> to create custom post types;</li>

   <li><a href="https://metabox.io/plugins/meta-box-builder/">Meta Box Builder:</a> to have an intuitive UI to create custom fields in the backend.</li>

</ul>

You can download and install each extension individually or use the <strong>Meta Box AIO</strong> which has all the Meta Box extensions.

The last one is <strong>Zion Builder</strong>. Make sure that you have <strong>Zion Builder Pro</strong> to have integration with Meta Box.

<h2>Step 1: Create a Custom Post Type</h2>

Go to <strong>Meta Box</strong> &gt; <strong>Post Types</strong> &gt; <strong>Add New</strong> to create a new post type for the recipe.

<img class="aligncenter" src="https://i.imgur.com/kOWxuCF.png" alt="Create a custom post type" width="1000" height="603" />

<h2>Step 2: Create Custom Fields</h2>

Move to<strong> Meta Box</strong> &gt; <strong>Custom Fields</strong> to create as many fields as you want.

<img class="aligncenter" src="https://i.imgur.com/XGXqPJH.png" alt="Create custom fields" width="1000" height="703" />

Here are the fields I use for this practice:

<img class="aligncenter" src="https://i.imgur.com/SiVQ6zM.png" alt="Created fields for the recipe page" width="1000" height="756" />

Pay attention to the <strong>Video</strong> field, we usually use the <strong>URL</strong> field to save links. If you use it, Zion Builder will display the link in text format only. Then, we must do something to convert the link into the video preview.

Instead, we'll use the <strong>oEmbed</strong> fields of Meta Box. This one allows you to save the link to display it as the video preview on the frontend directly.

<img class="aligncenter" src="https://i.imgur.com/B4Q7Vl5.png" alt="Use oEmbed fields of Meta Box to save the link and to display it as the video preview on the frontend directly" width="1000" height="607" />

After creating all the wanted fields, move to the <strong>Settings</strong> tab &gt; <strong>Location</strong> &gt; choose<strong> Post Type</strong> as <strong>Recipes</strong> to apply these fields to this post type.

<img class="aligncenter" src="https://i.imgur.com/8ANvIPe.png" alt="Set Location for the custom fields as the recipe post type" width="1000" height="642" />

Back to the post editor, you will see all of the newly created custom fields.

<img class="aligncenter" src="https://i.imgur.com/65lnBhg.png" alt="Newly created custom fields in the post editor" width="1002" height="793" />

<h2>Step 3: Create a Template</h2>

Go to the <strong>Zion Builder</strong> menu and create a new template.

First, choose the <strong>All Recipes</strong> option so that this template will be used for all posts of the <strong>Recipes</strong> post type.

<img class="aligncenter" src="https://i.imgur.com/z1tzj64.png" alt="Create a template and choose All Recipes option to apply it to all post of Recipe post type" width="1000" height="753" />

Next, set the template for the body of the page.

<img class="aligncenter" src="https://i.imgur.com/eQFaph4.png" alt="Set the template for the body of the page" width="1000" height="629" />

In the <strong>Page options</strong>, choose <strong>Dynamic data preview source</strong>. Select any post in the created post type to see its preview.

<img class="aligncenter" src="https://i.imgur.com/lSpZIty.png" alt="In the Page options, choose Dynamic data preview source" width="1003" height="774" />

Now, let's edit the template!

Select the layout with one column only to cover all of the recipe information.

<img class="aligncenter" src="https://i.imgur.com/6Fo0qRn.png" alt="Select a layout for the template" width="1000" height="780" />

To get the recipe's name, which is the title of the post, add a <strong>Heading</strong> element, then choose the <strong>Post Title</strong> option in the <strong>Use dynamic data</strong> section.

<img class="aligncenter" src="https://i.imgur.com/3UvudTD.png" alt="Add a Heading element and choose Post Title option to get the recipe's name" width="1000" height="650" />

For the first section of the page, I'll add a component with the layout as 2 columns.

<img class="aligncenter" src="https://i.imgur.com/MOtImVj.png" alt="Add a component with the layout as 2 columns" width="1006" height="631" />

In the first column, add an <strong>Image</strong> element. Since the dish image is also the featured image of the post, click on the <strong>Use Dynamic Data</strong> button &gt; choose <strong>Featured Image</strong> in the <strong>Post</strong> section.

<img class="aligncenter" src="https://i.imgur.com/St0yIcw.png" alt="Add an Image element, click Use Dynamic Data button and then choose Featured Image" width="1000" height="655" />

For the second column including all the timing information, add 4 <strong>Container</strong> element inside. Each container will be for a type of time.

<img class="aligncenter" src="https://i.imgur.com/dYy9aV2.png" alt="Choose the Text element, use the Dynamic Data for the timing information" width="1003" height="624" />

<img class="aligncenter" src="https://i.imgur.com/8Na1nn9.png" alt="Each container will be for a type of time." width="1000" height="755" />

In the first container, choose the <strong>Text</strong> element. As the timing information is saved in custom fields created by Meta Box, use the <strong>Dynamic Data</strong> button to connect this element to the Meta Box fields. Take the <strong>Prep Time</strong> field as an example.

<img class="aligncenter" src="https://i.imgur.com/bDZq8mG.gif" alt="Choose the Text element and use Dynamic Data button to connect this element to the Meta Box fields" width="1000" height="563" />

Then, choose the <strong>Heading</strong> element and name it. You can style it visually as you want.

We'll do the same in the next three containers.

Next, I'll add other containers for each section like ingredients, instruction, nutrition, etc. In each one, add the <strong>Heading</strong> element and name it. Next, click the <strong>Text</strong> element, then connect it to the corresponding field.

<img class="aligncenter" src="https://i.imgur.com/8Js5FIM.png" alt="Add containers for each section" width="1000" height="366" />

Now, it's time to display the video. I still use the <strong>Text</strong> element to display it because the <strong>Video</strong> element of Zion Builder has not yet supported getting dynamic data. Then, just change the link by inserting the dynamic data from the <strong>oEmbed</strong> field that we use to save the video's link.

<img class="aligncenter" src="https://i.imgur.com/q7HJQfY.png" alt="Insert the dynamic data from oEmbed field to save the video's link" width="1000" height="553" />

As you can see here, although using the <strong>Text</strong> component, the video preview still display as we want.

After finishing getting all of the recipe information, you will see all the recipe information is already displayed on the frontend.

<img class="aligncenter" src="https://i.imgur.com/yXgx2go.png" alt="All the recipe information is displayed in the frontend" width="1000" height="645" />

<h2>Step 4: Style the Page</h2>

Back to the page editor with <strong>Zion Builder</strong>, you can change the settings of each element to style them.

Here is an example result of how I styled the page in my way.

<img class="aligncenter" src="https://i.imgur.com/v9WMsy5.png" alt="Recipe page after styling" width="600" height="917" />

<h2>Last Words</h2>

Wishfully, the steps above will give you a hand to <strong>create a recipe page with Meta Box and Zion Builder</strong> easily.

Feel free to share your results with us in the comments. And, follow our channel to see more helpful tutorials!