How to Create Menu for a Restaurant - P1 - Using Meta Box and Elementor
Tags: tutorial, clonablefields, customfields, elementor
Published: 2022-08-09 06:39:15

For those who have a food online order website or something similar, your website will have a lot of restaurants for customers to choose from. <strong>Each restaurant definitely has its own menu</strong>. So, how to <strong>have different menus</strong> for them?

Let's see how to do it in this post. We’re going to use custom fields for menus with the support from Meta Box and Elementor in this practice.

<!--more-->

Here is my example:

<img class="aligncenter" src="https://i.imgur.com/zt6Mdaw.png" alt="Example of Restaurant's menu" width="1000" height="936" />
<h2>Video Version</h2>
https://youtu.be/mE_mtLz5lCA
<h2>Before Getting Started</h2>
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 fields. It’s free, so 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;</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://metabox.io/plugins/mb-elementor-integrator/">MB Elementor Integrator</a>: to connect and display custom fields created by Meta Box plugin in the Elementor's dynamic tags.</li>
</ul>
They’re all in the <strong>Meta Box AIO</strong>. If you haven’t had it, you can download and install each one individually.

Finally, make sure you have <strong>Elementor</strong> <strong>Pro</strong> on your site.
<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.

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

After publishing, we’ll have a new menu named <strong>Restaurants</strong>.

<img class="aligncenter" src="https://i.imgur.com/WfnjLM7.png" alt="The post type appear as a menu after creating." width="1003" height="669" />

Then, let’s create custom fields in the following step.
<h2>Step 2: Create Custom Fields</h2>
Go to <strong>Meta Box</strong> &gt; <strong>Custom Fields</strong> to create fields. I’ll create all the fields with the structure like this:
<table>
<tbody>
<tr>
<td><b>Name</b></td>
<td><b>Field type</b></td>
<td><b>Settings</b></td>
</tr>
<tr>
<td>Menu Details</td>
<td>Group</td>
<td>Collapsible
Cloneable</td>
</tr>
<tr>
<td>        Name</td>
<td>Text</td>
<td>-</td>
</tr>
<tr>
<td>        Price</td>
<td>Text</td>
<td>-</td>
</tr>
<tr>
<td>        Description</td>
<td>Text</td>
<td>-</td>
</tr>
<tr>
<td>        Image</td>
<td>Single Image</td>
<td>-</td>
</tr>
</tbody>
</table>
<img class="aligncenter" src="https://i.imgur.com/2Ax2rMj.png" alt="Go to Meta Box then Custom Fields to create fields" width="1000" height="430" />

This is a group with 4 subfields inside. These subfields are for the dish detail. So, each group will be for a dish only. To add more dishes, set this group to be cloneable.

<img class="aligncenter" src="https://i.imgur.com/YIx3yBc.png" alt="To add more dishes, set this group to be cloneable." width="1000" height="769" />

Then, there’ll be an <strong>Add more</strong> button to allow adding more dishes.

<img class="aligncenter" src="https://i.imgur.com/NFrLWmN.png" alt="Then, there’ll be an Add more button to allow adding more dishes." width="1000" height="403" />

In the event the restaurant has too many dishes, you can set the group to be collapsible.

<img class="aligncenter" src="https://i.imgur.com/RDxggHr.png" alt="In the event the restaurant has too many dishes, you can set the group to be collapsible." width="1000" height="708" />

It’ll be tidier when adding information for the menu like this.

<img class="aligncenter" src="https://i.imgur.com/kQZRO6I.png" alt="Adding information and it show so much tidier" width="1000" height="403" />

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

<img class="aligncenter" src="https://i.imgur.com/nQ2ZMor.png" alt="Move to the Settings tab, choose Location as Post Type and select Restaurant to apply these fields" width="1000" height="402" />

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

<img class="aligncenter" src="https://i.imgur.com/Tv7fWAc.png" alt="fill in the dishes’ details with the created fields in post editor" width="1000" height="731" />
<h2>Step 3: Create a Skin</h2>
Go to <strong>Templates</strong> &gt; <strong>Theme Builder</strong> &gt; <strong>Meta Box Group Skin</strong> &gt; <strong>Add New</strong> to create a new skin.

<img class="aligncenter" src="https://i.imgur.com/zaHjbZ7.png" alt="Go to Templates &gt; Theme Builder" width="1001" height="533" />

<img class="aligncenter" src="https://i.imgur.com/AsSMDrN.png" alt="Meta Box Group Skin &gt; Add New to create a new skin." width="1000" height="564" />

Set the settings for the skin as you want and remember to choose a post for preview. Then, add the <strong>Heading</strong> element for the name of the dish.

<img class="aligncenter" src="https://i.imgur.com/oqaxrPl.png" alt="add the Heading element for the name of the dish." width="1000" height="459" />

To get the name of the dish saved in custom fields, click the<strong> Dynamic Tags</strong> button in the settings of the <strong>Heading</strong> element. There’ll be a list. Choose the <strong>Meta Box Field</strong> in the <strong>Post</strong> section.

<img class="aligncenter" src="https://i.imgur.com/5hFozpI.png" alt="Choose the Meta Box Field in the Post section." width="1002" height="427" />

<strong>Note</strong>: Since our custom fields are created for a post type, find the <strong>Meta Box Field</strong> in the <strong>Post</strong> section. In case the custom fields are for a settings page or something else, look for the <strong>Meta Box Field</strong> in the corresponding section in the list.

Then, choose the name of the field you want to get the name of the dish from.

<img class="aligncenter" src="https://i.imgur.com/MtzOjK0.png" alt="Choose the name of the field you want to get the name of the dish from." width="1000" height="471" />

For price and description of the dish, add the <strong>Text Editor</strong> element. Once again, use the <strong>Dynamic Tags</strong> &gt; <strong>Meta Box Fields</strong> in the <strong>Post</strong> section, then choose the corresponding fields.

For the image of the dish, add an <strong>Image</strong> element. Also use the <strong>Dynamic</strong> <strong>Tags</strong> and select the <strong>Image</strong> field.

<img class="aligncenter" src="https://i.imgur.com/NxnJxmf.png" alt="For the image of the dish, add an Image element. Also use the Dynamic Tags and select the Image field." width="1000" height="750" />

As you can see, it’ll automatically get and display the information saved in the first group (means the 1st dish) only.
<h2>Step 4: Create a Template for the Menu</h2>
Back to the <strong>Theme</strong> <strong>Builder</strong> &gt; <strong>Single</strong> <strong>Post</strong> to create a new template for post.

<img class="aligncenter" src="https://i.imgur.com/QbLvPzB.png" alt="Back to the Theme Builder &gt; Single Post to create a new template for post." width="998" height="467" />

Similar to the skin, remember to set the preview for this template.

Find and add the <strong>Meta Box Group</strong> element to the template.

<img class="aligncenter" src="https://i.imgur.com/FScgkh5.png" alt="Find and add the Meta Box Group element to the template." width="1000" height="460" />

Then, there’ll be some posts displayed in the preview. But it may not be the information from the posts you want.

<img class="aligncenter" src="https://i.imgur.com/h2IqKYJ.png" alt="the Object Type of the template is set by default as Post and the Group section will automatically set as the created-lastest group" width="1000" height="737" />

Look at the left sidebar, the <strong>Object</strong> <strong>Type</strong> of the template is set by default as <strong>Post</strong> and the <strong>Group</strong> section will automatically set as the created-lastest group. If it is not the group field you want, you can change them to the right one.

Then all the data will be displayed correctly, but there is no styling.

For styling, in the <strong>Skin</strong> section, choose the skin that you’ve created in the previous step. Then, it will turn to the new look with the style of the created skin.

<img class="aligncenter" src="https://i.imgur.com/sAe04lk.png" alt="For styling, in the Skin section, choose the skin that you’ve created in the previous step" width="1000" height="784" />

To have more styling, you can add some decoration for the template as I did.

<img class="aligncenter" src="https://i.imgur.com/hAkHNIj.png" alt="To have more styling, you can add some decoration for the template" width="1000" height="678" />

However, because the elements which are the dish detail are set in the skin, you need to go back to the created skin to style them.

<img class="aligncenter" src="https://i.imgur.com/uFwUmU0.png" alt="Because the elements which are the dish detail are set in the skin, you need to go back to the created skin to style them" width="1000" height="660" />

Then all the changes in the skin will be automatically applied in the template.

Here is the result we’ve got after all the styling.

<img class="aligncenter" src="https://i.imgur.com/zt6Mdaw.png" alt="Here is the result we’ve got after all the styling" width="1000" height="936" />
<h2>The Verdict</h2>
Do you see that using custom fields to have a menu for each restaurant is a brilliant way? If you see this practice is helpful, try it and share the result with us.

If you are using other ways, wait for our upcoming tutorials. Keep track of our blog and good luck!