How to Create a Recipe - P2 - Using Meta Box and Oxygen
Tags: tutorial, recipe, oxygen, metabox
Published: 2022-09-27 02:31:21



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpd1xs44sfhcsflhk0fw.jpg)Creating an impressive, eye-catching recipe is essential for culinary website owners. There are many ways to create a beautiful one. <a href="https://metabox.io/wordpress-create-recipe-with-meta-box-plugin/">In the first part</a>, we used only Meta Box, which allows us to create custom post types and custom fields, to do it.

<!--more-->

If you use page builders, then follow this post or the articles in <a href="https://metabox.io/series/recipe/">this series</a>. And now, let’s see <strong>how to create a recipe with Meta Box and Oxygen.</strong>

<img class="aligncenter" src="https://i.imgur.com/rX9SGdE.png" alt="Example of a Recipe" width="500" height="870" />
<h2>Video Version</h2>
https://youtu.be/95DviTWI25o
<h2>Before Getting Started</h2>
In this tutorial, all of the information about the recipe will be saved in posts of a custom post type. The recipe’s name and the dish picture are the title and the featured image of the post. Besides, the remaining detailed information will be saved in the custom fields.

The necessary tools are listed below:

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

To have advanced features of Meta Box, we need some 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 includes all the Meta Box extensions.

The last one is <a href="https://oxygenbuilder.com/">Oxygen</a>. You should use the 3.9 version or higher which has the native integration with Meta Box already.
<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/RABAgP1.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>, then create fields as you want.

<img class="aligncenter" src="https://i.imgur.com/hMEoDLf.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/pWljhJt.png" alt="Field group created" width="1001" height="757" />

Pay attention to the video information. Normally, we use the <strong>URL</strong> field to save links, but if you use it, Oxygen will display the link in text format only. Then, we must take a few more steps to convert the link into the video preview.

However, Meta Box has the <strong>oEmbed</strong> fields that allow you to save the link and display it as the video preview on the frontend directly. So, we’ll use it for more convenience.

<img class="aligncenter" src="https://i.imgur.com/bjmwlGC.png" alt="Create oEmbed fields to save the link and display it as the video preview on the frontend" width="1000" height="687" />

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

<img class="aligncenter" src="https://i.imgur.com/hIBUV0X.png" alt="Set location for 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/f56IhBp.png" alt="Newly created custom fields" width="1002" height="793" />
<h2>Step 3: Create a Template with Oxygen</h2>
Go to the <strong>Oxygen</strong> menu and create a new template.

In the settings of the template, select a design that you want the template to inherit from, then choose your post type in the <strong>Singular</strong> section to apply the template to it.

<img class="aligncenter" src="https://i.imgur.com/v7yxRNu.png" alt="Select the wanted design for the template to be inherited from." width="1000" height="825" />

Now, create a new post in that post type. You’ll see that the template is already rendered for this product page already.

<img class="aligncenter" src="https://i.imgur.com/DyNtTuL.png" alt=" The template is rendered for this product page" width="1000" height="746" />

After filling in the information for the recipe, let’s edit the template with Oxygen.

First, select a <strong>Section</strong> component to contain all of the recipe information.

<img class="aligncenter" src="https://i.imgur.com/Dx2dg0D.png" alt="Select a Section" width="1000" height="684" />

To get the recipe’s name, which is the title of the post, add a <strong>Heading</strong> component. Then, connect it to the post title to get data.

<img class="aligncenter" src="https://i.imgur.com/Fn0YwT4.gif" alt="Add a Heading component and connect it to the post title to get data." width="1920" height="1080" />

In the first section, I’ll divide the content into 2 columns like this:

<img class="aligncenter" src="https://i.imgur.com/Dm1ogHm.png" alt="Divide the content into 2 columns" width="1000" height="567" />

So, add a Column component. Then, there’ll be 2 <strong>div</strong> tags available inside it, equivalent to 2 columns. In the first div tag, add the <strong>Featured</strong> <strong>Image</strong> component to get the dish’s image.

<img class="aligncenter" src="https://i.imgur.com/YZpgSjH.png" alt="Add a Column component and select Featured Image for the 1st Div tag" width="1000" height="595" />

Move to the second column, which covers all the information about the completed time. I’ll add an extra <strong>div </strong>inside it. This div is for a row.

<img class="aligncenter" src="https://i.imgur.com/c6uJEsA.png" alt="Add an extra div inside as for the row" width="1000" height="567" />

Inside this div, add a <strong>Text</strong> component, and connect it to the field that saves the corresponding time information. Then, choose the Heading component and name it. Finally, style the row in your own way.

<img class="aligncenter" src="https://i.imgur.com/XGYqe77.png" alt="Add a Text component, and connect it to the field that saves the corresponding time information" width="1000" height="433" />

Then, you can duplicate the div which is used for the first row to have more rows. Then, change the names and fields.

<img class="aligncenter" src="https://i.imgur.com/kwRlvQn.png" alt="Duplicate the div and change the name and fields" width="1000" height="459" />

For the rest section, we create another <strong>div</strong> in the <strong>Section</strong> component. Inside this div, choose the <strong>Heading</strong> component and name it, e.g. Ingredients. Also, add the <strong>Text</strong> component, then connect it to the corresponding field which saves the information about the ingredients, instructions, note, nutrition, equipment.

For the video information, there is a difference. Replace the Text component by the Video.

To display that data, I'll add a <strong>Video</strong> component. Then, just change the link by inserting the dynamic data from the oEmbed field that we use to save the video’s link.

<img class="aligncenter" src="https://i.imgur.com/MiT0Wh7.gif" alt="Add a Video component to display data" width="1920" height="1080" />

We’ve finished getting all of the recipe information. Back to the frontend, you see all of them are already displayed.

<img class="aligncenter" src="https://i.imgur.com/UNvyaOG.png" alt="Back to the frontend, everything is well displayed" width="600" height="872" />
<h2>Step 4: Style the Page</h2>
Back to the page editor with Oxygen, choose each component, and change the settings to style them.

I’ll style the time section for example. To save time of styling, I’ll use a class for 4 rows to make them have the same look. Name the class for each one like this.

<img class="aligncenter" src="https://i.imgur.com/5S1rCSw.png" alt="Use a class to style for 4 rows to safe time" width="1000" height="715" />

Style a row as you want, then these 4 rows will change the style at once.

Go to the recipe page on the frontend, you’ll see the new look.

<img class="aligncenter" src="https://i.imgur.com/rX9SGdE.png" alt="Result after styling" width="500" height="870" />
<h2>Last Words</h2>
We have finished <strong>creating a recipe page with</strong> <strong>Meta Box and Oxygen</strong>. As you can see, with custom fields, you can easily save extra information about the recipe and display it in a more beautiful style. Let’s try and share the result with us in the comments.

Don’t forget to follow our channel to see other ways to have useful recipes!