How to Create a Product Page - P4 - Using Meta Box and Elementor
Tags: tutorial, customfield, dynamicdata, elementor
Published: 2023-01-17 01:44:52

Let’s see <strong>how to create a great product page</strong> using <strong>Meta Box</strong> and <strong>Elementor</strong> with some simple steps! I also take a car rental for the product as an example.

<!--more-->

<img class="aligncenter" src="https://i.imgur.com/eR5DcdE.png" alt="Example of a product page" width="1000" height="594" />
<h2>Video Version</h2>
https://youtu.be/gI0M5nuzPj8
<h2>Before Getting Started</h2>
The product page is a singular page. All of its information is saved in a post of a custom post type. The name of the product and its descriptions are the title and content of the post. The remaining detailed information will be saved in the custom fields that are created by <strong>Meta Box</strong>.

<img class="aligncenter" src="https://i.imgur.com/DaLle8J.png" alt="A product page is a singular page" width="1000" height="563" />

So, in this practice, we need these tools:
<ul>
 	<li><a href="https://wordpress.org/plugins/meta-box/">Meta Box core plugin</a>: to have a framework to create a custom post type and custom fields;</li>
 	<li><a href="https://metabox.io/plugins/custom-post-type/">MB Custom Post Type</a>: to create custom post types for the products;</li>
 	<li><a href="https://metabox.io/plugins/meta-box-builder/">Meta Box Builder</a>: to have a UI on the back end to create custom fields easily;</li>
 	<li><a href="https://metabox.io/plugins/mb-elementor-integrator/">Meta Box - Elementor Integrator</a>: to get the dynamic data from custom fields created by Meta Box;</li>
 	<li><strong>Elementor</strong> to build the page. I’m using <strong>Elementor Pro</strong>, which has integration with Meta Box.</li>
</ul>
<h2>Create a New Custom Post Type</h2>
Go to <strong>Meta Box &gt; Post Types &gt; New Post Type</strong> to create a new custom post type.

<img class="aligncenter" src="https://i.imgur.com/1UoEKF3.png" alt="Create a new custom post type" width="1000" height="689" />
<h2>Create Custom Fields</h2>
The product has extra detailed information, so we’ll create custom fields to save them. Go to <strong>Meta Box &gt; Custom Fields</strong>, then create fields as you want.

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

In my case, I just take a typical example of car rental with some common fields. Here are the fields that I created.

<img class="aligncenter" src="https://i.imgur.com/W1deiPo.png" alt="The created custom fields" width="1000" height="800" />

To know more about the field type, you may have your own specific information for the product. So, you may want to find out each field type to get the matching one. We have a video to talk about <a href="https://youtu.be/WWeaM5vIAwM">all the field types of Meta Box</a> in detail. You can dig into it.

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

<img class="aligncenter" src="https://i.imgur.com/I1gm1Oa.png" alt="Set location for the created custom fields as post type" width="1000" height="609" />

In the post editor, you will see all of the created custom fields.

<img class="aligncenter" src="https://i.imgur.com/SjBBCpL.png" alt="All created fields in the post editor" width="1006" height="790" />
<h2>Create a Template</h2>
Go to the <strong>Elementor Theme Builder</strong> and create a new template. Since it’s for a singular page of a custom post type, we’ll create it in the type of a single post.

<img class="aligncenter" src="https://i.imgur.com/yyXmCoo.png" alt="Create a template" width="1000" height="366" />

After setting the preview for the template, let’s edit it.

My product page has two columns like this:

<img class="aligncenter" src="https://i.imgur.com/YcW9Ksx.png" alt="Two columns of the product page" width="1000" height="401" />

So, first, add a widget and choose the layout for it.

<img class="aligncenter" src="https://i.imgur.com/qgwzmNm.png" alt="Add a widget and choose the layout" width="1000" height="561" />

In the first column, select the <strong>Image Carousel</strong> to display the image gallery as a slider. Then, to get the image that is saved in the custom field, go to the <strong>Dynamic Tags</strong>, find the <strong>Meta Box Field</strong> in the <strong>Post</strong> section, and choose the field that is set for the image. After that, you can see all of the images appear

<img class="aligncenter" src="https://i.imgur.com/RkfR1jo.gif" alt="Find the corresponding field to get the data by using Dynamic Data" width="1000" height="563" />

Move to the second column to display other information about the product. The first one is the product's name which is saved in the post title. So, choose the <strong>Post Title</strong> element &gt; select the <strong>Post Content</strong> element to get the product’s description.

<img class="aligncenter" src="https://i.imgur.com/3uJDuKv.png" alt="Choose the post title element for the product's description" width="1000" height="379" />

For the rental price information, choose the <strong>Text Editor</strong> element. Since the rental price is saved in custom fields created by Meta Box, also use the <strong>Dynamics Tags &gt; Meta Box Field</strong> in the <strong>Post</strong> section &gt; choose the corresponding fields. A number will be displayed without a unit of the pricing.

<img class="aligncenter" src="https://i.imgur.com/JKWxASC.gif" alt="Choose the Text Editor element for the rental price information" width="1000" height="563" />

To have the unit displayed, go to the <strong>Advanced</strong> section, and add the currency unit.

<img class="aligncenter" src="https://i.imgur.com/M9prrn2.png" alt="Add the currency unit in the Advanced section" width="1000" height="397" />

For the rest of the information in this section, they have the same style with 2 columns. The first one is the title, and the second one is the information that is obtained from the custom fields.

<img class="aligncenter" src="https://i.imgur.com/SDHPQ9D.png" alt="The rest of the information will have the same style with 2 columns" width="1000" height="404" />

Thus, we’ll use the <strong>Inner Section</strong> with 2 columns as well for each row.

<img class="aligncenter" src="https://i.imgur.com/quyDxUW.png" alt="Use the Inner Section with 2 columns" width="1000" height="563" />

<img class="aligncenter" src="https://i.imgur.com/HDkwhM1.png" alt="2 columns for each row" width="1000" height="559" />

The first column is the title. So, select the <strong>Heading</strong> element, then just name and style it.

<img class="aligncenter" src="https://i.imgur.com/uSpRUnR.png" alt="Select the Heading element for the title" width="1000" height="561" />

In the second column in the <strong>Inner Section</strong> element, add a <strong>Text Editor</strong> element, then connect it to the custom field to get the data using the dynamic tags. Take <strong>Car Year</strong> as an example.

<img class="aligncenter" src="https://i.imgur.com/dsNR88Q.gif" alt="Add a Text Editor element in the Inter Section element then connect it to the right field" width="1000" height="563" />

You can duplicate the <strong>Inner Section</strong> to have other rows and change the information to get the right one.

After getting all of the information about the product, remember to set the condition for this template to apply it to the singular page of the <strong>Car Rental</strong>.

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

Now, in the frontend, all of the product's detailed information is displayed.

<img class="aligncenter" src="https://i.imgur.com/Ije0Xxw.png" alt="All the product's information is displayed" width="1000" height="588" />
<h2>Style the Page</h2>
Still in the editor of the created template, just customize each element to get the wanted style.

<img class="aligncenter" src="https://i.imgur.com/Nek1KHd.png" alt="Style the Page" width="1000" height="471" />

After styling, you’ll see the new look.

<img class="aligncenter" src="https://i.imgur.com/eR5DcdE.png" alt="The final result after styling " width="1000" height="594" />
<h2>Last Words</h2>
Hopefully, all the following steps above can give you a hand in creating a detailed product page. If you use other page builders, you can dig into <a href="https://metabox.io/series/product-page/">the series on how to create a product page with different page builders</a>.

If you want to suggest any tutorials, feel free to leave a comment. Thank you for reading. Good luck!