How to Create a Recipe - P6 - Using Meta Box and Brizy
Tags: tutorial, customfields, dynamicdata, brizy
Published: 2023-03-14 02:37:33

In the prior posts of <a href="https://metabox.io/series/recipe/">this series</a>, we’ve known how to <strong>create a Recipe page</strong> using some of the page builders. In today's practice, we’ll use another one named <strong>Brizy</strong> to do it with the help of <strong>Meta Box</strong>.

<!--more-->

This is an example:

<img class="aligncenter" src="https://i.imgur.com/f1XeFRO.png" alt="The example of created recipe" width="1000" height="778" />
<h2>Video Version</h2>
https://youtu.be/wCKxZEQ4uRE
<h2>Before Getting Started</h2>
Each recipe is saved in a post of a custom post type and displayed in a single page. Besides some default fields that may help to save some basic information. You may want to have more space for the extra ones. So, we need custom fields for them.

To get started, 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. It’s free and you can download it directly from <a href="https://wordpress.org/plugins/meta-box/">wordpress.org</a>.

For the advanced features from 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 and custom taxonomies;</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>
 	<li><a href="https://www.brizy.io/">Brizy</a> (Brizy Pro version): to build the pager.</li>
</ul>
<h2>Create a Custom Post Type</h2>
Go to <strong>Meta Box &gt; Post Types &gt; Add New</strong> to create a new post type.

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

After publishing, we’ll have a menu named <strong>Recipe</strong> in the <strong>Admin Dashboard</strong>.

<img class="aligncenter" src="https://i.imgur.com/TJDJRAH.png" alt="Created post type appears in the Admin Dashboard" width="1002" height="620" />

Let’s create custom fields in the next step.
<h2>Create Custom Fields</h2>
Go to <strong>Meta Box &gt; Custom Fields</strong> to create fields. These are the fields that I created:

<img class="aligncenter" src="https://i.imgur.com/NExew0x.png" alt="Created fields" width="1132" height="766" />

Pay attention to a special field for the video. Since <strong>Brizy</strong> supports displaying the video preview from the link saved in the type of text. So, instead of using the <strong>URL</strong> field or the <strong>oEmbed</strong> to save the video link as other tutorials, I’ll use the <strong>Text</strong> field.

<img class="aligncenter" src="https://i.imgur.com/MxWOuhb.png" alt="Use Text field to save the link of video" width="1000" height="271" />

After creating all the fields, move to the <strong>Settings</strong> tab, choose <strong>Location</strong> as <strong>Post Type</strong> and then select <strong>Recipe</strong> to apply these fields to it.

<img class="aligncenter" src="https://i.imgur.com/QrBZDjK.png" alt="Set location for the created fields" width="1000" height="487" />

Then, you can easily see all the created custom fields in the post editor. Just fill in the recipe’s details.

<img class="aligncenter" src="https://i.imgur.com/auwABHx.png" alt="Created fields display in the post editor" width="1008" height="599" />
<h2>Create the Page</h2>
Go to <strong>Brizy &gt; Templates</strong> to create a new template.

<img class="aligncenter" src="https://i.imgur.com/gFHul7c.png" alt="Create the Page" width="1000" height="453" />

Remember to set the condition to set this template for the single post/page of the Recipe.

<img class="aligncenter" src="https://i.imgur.com/WqXrE6r.png" alt="Set the condition for the page" width="1000" height="535" />

First, go to the <strong>Global Blocks</strong> to set the header for the page.

<img class="aligncenter" src="https://i.imgur.com/mRv2sII.png" alt="Set the header for the page" width="1000" height="163" />

To display the name of the recipe, add a <strong>Title</strong> element. It’ll automatically get the data from the post title.

<img class="aligncenter" src="https://i.imgur.com/Gcw0QQo.png" alt="Add a title element" width="1000" height="443" />

For the first section, I divided information into two columns. One column is for the image of the recipe and the other is for the timing information. So, add a <strong>Column</strong> element.

<img class="aligncenter" src="https://i.imgur.com/7POiMkt.png" alt="Add a Column element" width="1000" height="443" />

Drag the <strong>Featured Image</strong> element to the first column. The image will be displayed immediately.

<img class="aligncenter" src="https://i.imgur.com/ZFhVSYX.png" alt="Drag the Featured Image element to the first column" width="1000" height="623" />

Next, I’ll add <strong>Row</strong> inside the second column. Each row will be used for each type of timing information.

<img class="aligncenter" src="https://i.imgur.com/sKxGm8I.png" alt="Add Row inside the second column" width="1000" height="623" />

Inside the row, add a <strong>Text</strong> element, then choose <strong>Typography</strong> to customize the text. You will see a small icon button to choose more options from a dropdown list for the text.

The first one is to add a custom text that you can type any text as you want into the element. All the rest ones on the list are the names of custom fields. Since we save the data about the time in custom fields, choose the corresponding ones.

<img class="aligncenter" src="https://i.imgur.com/A9hUdcZ.gif" alt="Choose Typography element" width="1000" height="562" />

To compare the type of time, add another <strong>Text</strong> element. Set it as <strong>Custom Text</strong> to change the text into the type of time.

<img class="aligncenter" src="https://i.imgur.com/Z5S2yQW.gif" alt="Add another Text element" width="1000" height="562" />

For other information about the time, do likewise.

<img class="aligncenter" src="https://i.imgur.com/i0b7XC8.png" alt="Do likewise with other information" width="999" height="742" />

Now, let’s get the <strong>Ingredient</strong> section. Add a <strong>Text</strong> element and set it as a heading. Then, type the name of the section.

<img class="aligncenter" src="https://i.imgur.com/3Pk7CNl.png" alt="Add a text element and set it as a heading" width="1000" height="663" />

To display the information about the ingredients that is stored in custom fields, add another <strong>Text</strong> element below the heading and also connect it to a custom field. The content will be displayed immediately.

<img class="aligncenter" src="https://i.imgur.com/uD14rHX.gif" alt="Add another Text element" width="1000" height="562" />

For other sections, just do the same.

In the <strong>Video</strong> section, instead of adding <strong>Text</strong>, add a <strong>Video</strong> element. A default video will be displayed.

<img class="aligncenter" src="https://i.imgur.com/bVgDpg5.png" alt="Add a Video element for the Video section" width="1000" height="679" />

To display the video about the recipe, click to the preview button. Beside the pre-set link, there is also the icon to connect with custom fields.

<img class="aligncenter" src="https://i.imgur.com/N1XCATf.png" alt="Click the preview button" width="1000" height="774" />

We’ve done getting all the information about the recipe. Add a new block and then go to the Global Blocks section once again to add the footer for the page.

This is how it displays on the frontend.

<img class="aligncenter" src="https://i.imgur.com/VdhHvbY.png" alt="All the information has been obtained" width="1000" height="775" />
<h2>Style the Page</h2>
Back to the template editor of <strong>Brizy</strong>, you can change the column width as well as the settings of each element to have the style as you want. Just customize one by one, then you will see the new look of the page.

<img class="aligncenter" src="https://i.imgur.com/c0A39P2.png" alt="Change the column width" width="1000" height="436" />

Here is the result that I want.

<img class="aligncenter" src="https://i.imgur.com/f1XeFRO.png" alt="The final result" width="1000" height="778" />
<h2>Last Words</h2>
We've found out how to create a Recipe page using <strong>Meta Box</strong> and <strong>Brizy</strong>. More information is available here if you use other page builders. Keep an eye on our site for more insightful tutorials and feel free to suggest any ideas for us. Good luck!