When you visit food websites or food blogs, you may find beautiful recipes that are presented professionally. To create these recipes, in addition to using a dedicated recipe plugin, we can also use custom fields and custom post types with Meta Box plugin. In this article, we’re going to learn how to do it step by step.

Tip: a tutorial video is included at the end of this post.

For better illustration, these are examples of recipes that I found on a food blog. And we are going to create the same one:

The recipe on a food blog

Before Getting Started

First of all, you need to install and activate these tools:

  • Core plugin Meta Box (free): a framework that helps you work with custom fields and meta boxes more easily.
  • MB Custom Post Types & Custom Taxonomies (free): this is an extension to create custom post types for posting recipes easily and quickly. It can run independently without Meta Box plugin.
  • Meta Box Builder (premium): this is an extension that provides us with an intuitive UI right on the back end. It allows you to create custom fields more conveniently with drag and drop actions. To use this extension, you need to install Meta Box plugin first.
  • MB Views: this is an extension of Meta Box plugin to get and display the custom fields value on the front end without adding code to the theme file.
  • eStar theme: this free WordPress theme has hooks that help you display custom fields on the front end easily and conveniently.

In addition, you can use free tools Post Type Generator and Online Generator to create custom post types and custom fields without installing the two above extensions. Read the documentation of Post Type Generator here and the documentation of Online Generator here.

After you had all the needed tools, follow these steps below to create a recipe with Meta Box plugin:

Step 1: Create the Custom Post Type Recipe and Its Custom Fields

First, I will create the Recipe custom post type for posting recipes.

Read more: How to create a custom post type in WordPress using code and plugin?

Go to Meta Box > Post Types > New Post Types:

Create the Recipe custom post type for posting recipes with Meta Box plugin.

I created the Recipe post type with the following information:

Created the Recipe post type with Meta Box plugin.

As you can see at the beginning, a recipe usually has items such as preparation time, cooking time, equipment, ingredients, instruction, notes, nutrition, etc. To add these items, I will create the corresponding custom fields Prep time, Cook time, Resting time, Total time, Equipment, Ingredients, Instructions,… for the Recipe post type.

Go to Meta Box > Custom Fields > Add New to create new custom fields for the recipe. The fields are created with the following field types and field names:

Field Name Field Type
Prep time text
Cook time text
Resting time text
Total time text
Ingredients wysiwyg
Instructions wysiwyg
Video text
Notes wysiwyg
Nutrition wysiwyg
Equipment wysiwyg

Read more: How to Add and Configure Custom Fields Using Meta Box Builder.

These are the fields that I’ve created:

The custom fields for the recipe post type

Upon creating fields, move to the Settings tab and choose the post type as recipe:

Choose the post type as recipe

Ok, now we have the recipe custom post type with all the needed custom fields.

Next, go to Recipe > Add Recipe:

Add a new recipe

After that, drag to the bottom, you can see the custom fields that we’ve created for the recipe post type. You need to fill in these fields. For example, I enter the pizza recipe as follows:

Fill in the custom fields for the food recipe

We’ve filled in the information for the custom fields, but the recipe still hasn’t been displayed on the WordPress website yet:

the recipe still hasn’t been displayed on the WordPress website yet

Therefore, we need to get the custom fields’ values and display them on the front end of the WordPress website.

Step 2: Display the Custom Fields’ Data on the Front End

I will display the custom fields in a hook of eStar theme that is ‘estar_entry_footer_before’. Refer to this hook here.

To get and display the custom fields’ value on the front end, there are two methods:

  • Method 1: Add code to the theme file
  • Method 2: Use MB Views extension

Method 1: Add Code to the Theme File

Add the following code to the functions.php of the theme:

add_action( 'estar_entry_footer_before', 'estar_child_recipe' );
function estar_child_recipe() {
	if ( ! is_singular( 'recipe' ) ) {
		return;
	}
	$ingredients = rwmb_meta( 'ingredients' );
	$instructions = rwmb_meta( 'instructions' );
	$equipment = rwmb_meta( 'equipment' );
	$video = rwmb_meta( 'video' );
	$notes = rwmb_meta( 'note' );
	$nutrition = rwmb_meta( 'nutrition' );
	$prep_time = rwmb_meta( 'prep_time' );
	$cook_time = rwmb_meta( 'cook_time' );
	$resting_time = rwmb_meta( 'resting_time' );
	$total_time = rwmb_meta( 'total_time' );
	?>
	<div class="recipe-food__container">
		<h2 class="recipe-name">Recipe</h2>
		<div class="recipe-group recipe-times">
			<h3 class="recipe-header">
				<div class="recipe-line"></div>
			</h3>
			<div class="recipe-times__container">
				<div class="recipe-times__item">
					<span class="label">Prep Time</span>
					<span class="recipe-time"><?php echo $prep_time; ?></span>
				</div>
				<div class="recipe-times__item">
					<span class="label">Cook Time</span>
					<span class="recipe-time"><?php echo $cook_time; ?></span>
				</div>
				<div class="recipe-times__item">
					<span class="label">Resting Time</span>
					<span class="recipe-time"><?php echo $resting_time; ?></span>
				</div>
				<div class="recipe-times__item">
					<span class="label">Total Time</span>
					<span class="recipe-time"><?php echo $total_time; ?></span>
				</div>
			</div>
		</div>
		<div class="recipe-group recipe-equipment">
			<h3 class="recipe-header">
				Equipment
				<div class="recipe-line"></div>
			</h3>
			<?php echo do_shortcode( wpautop( $equipment ) ); ?>
		</div>
		<div class="recipe-group recipe-ingredients">
			<h3 class="recipe-header">
				Ingredients
				<div class="recipe-line"></div>
			</h3>
			<?php echo $ingredients; ?>
		</div>
		<div class="recipe-group recipe-instructions">
			<h3 class="recipe-header">
				Instructions
				<div class="recipe-line"></div>
			</h3>
			<?php echo $instructions; ?>
		</div>
		<div class="recipe-group recipe-video">
			<h3 class="recipe-header">
				Video
				<div class="recipe-line"></div>
			</h3>
			<?php echo wp_oembed_get( $video ); ?>
		</div>
		<div class="recipe-group recipe-notes">
			<h3 class="recipe-header">
				Notes
				<div class="recipe-line"></div>
			</h3>
			<?php echo $notes; ?>
		</div>
		<div class="recipe-group recipe-nutrition">
			<h3 class="recipe-header">
				Nutrition
				<div class="recipe-line"></div>
			</h3>
			<?php echo $nutrition; ?>
		</div>
	</div>
	<?php
}

The above code is to display the custom fields’ data on the front end, in the ‘estar_entry_footer_before’ hook.

Explanation:

  • ‘estar_child_recipe' is the function name, you can set it on a whim.
  • 'ingredients' , 'instructions' , 'equipment' , 'video' , 'note' , 'nutrition' , 'prep_time' , 'cook_time' , 'resting_time', 'total_time' are the IDs of custom fields.

Method 2: Use MB Views Extension

If you don’t want to touch the theme files, you can use MB Views extension of Meta Box plugin.

First, go to Meta Box > Views > Add New:

Next, add the following code in the Template tab:

{% set ingredients = mb.rwmb_meta( 'ingredients' ) %}
{% set instructions = mb.rwmb_meta( 'instructions' ) %}
{% set equipment = mb.rwmb_meta( 'equipment' ) %}
{% set video = mb.rwmb_meta( 'video' ) %}
{% set notes = mb.rwmb_meta( 'note' ) %}
{% set nutrition = mb.rwmb_meta( 'nutrition' ) %}
{% set prep_time = mb.rwmb_meta( 'prep_time' ) %}
{% set cook_time = mb.rwmb_meta( 'cook_time' ) %}
{% set resting_time = mb.rwmb_meta( 'resting_time' ) %}
{% set total_time = mb.rwmb_meta( 'total_time' ) %}

<div class="recipe-food__container">
	<h2 class="recipe-name">Recipe</h2>
	<div class="recipe-group recipe-times">
		<h3 class="recipe-header">
			<div class="recipe-line"></div>
		</h3>
		<div class="recipe-times__container">
			<div class="recipe-times__item">
				<span class="label">Prep Time</span>
				<span class="recipe-time">{{ prep_time }}</span>
			</div>
			<div class="recipe-times__item">
				<span class="label">Cook Time</span>
				<span class="recipe-time">{{ cook_time }}</span>
			</div>
			<div class="recipe-times__item">
				<span class="label">Resting Time</span>
				<span class="recipe-time">{{ resting_time }}</span>
			</div>
			<div class="recipe-times__item">
				<span class="label">Total Time</span>
				<span class="recipe-time">{{ total_time }}</span>
			</div>
		</div>
	</div>
	<div class="recipe-group recipe-equipment">
		<h3 class="recipe-header">
			Equipment
			<div class="recipe-line"></div>
		</h3>
		{{ mb.wpautop( equipment ) }}
	</div>
	<div class="recipe-group recipe-ingredients">
		<h3 class="recipe-header">
			Ingredients
			<div class="recipe-line"></div>
		</h3>
		{{ ingredients }}
	</div>
	<div class="recipe-group recipe-instructions">
		<h3 class="recipe-header">
			Instructions
			<div class="recipe-line"></div>
		</h3>
		{{ instructions }}
	</div>
	<div class="recipe-group recipe-video">
		<h3 class="recipe-header">
			Video
			<div class="recipe-line"></div>
		</h3>
		{{ mb.wp_oembed_get( video ) }}
	</div>
	<div class="recipe-group recipe-notes">
		<h3 class="recipe-header">
			Notes
			<div class="recipe-line"></div>
		</h3>
		{{ notes }}
	</div>
	<div class="recipe-group recipe-nutrition">
		<h3 class="recipe-header">
			Nutrition
			<div class="recipe-line"></div>
		</h3>
		{{ nutrition }}
	</div>
</div>

After that, scroll down to the Settings section to choose the post type as recipe. You need to choose Singular in the Type section and choose recipe in the Location section.

Whichever method you choose, remember to fill in the right IDs of the custom fields.

Upon finishing, the recipe displays on the WordPress website as follows:

The custom fields’ data is now displayed on the front end. However, the recipe doesn’t look so beautiful. Therefore, I will style it a bit with CSS for better display.

Step 3: Style the Recipe with CSS

Go to Customizer > Additional CSS and add the CSS code. You can refer to my CSS code below:

.recipe-food__container {
	border: 1px solid #E0E0E0;
	padding: 20px;
	background: #b0e4e4;
}
.recipe-food__container p {
	margin-bottom: 5px;
}
.recipe-group {
	margin-bottom: 30px;
}

.recipe-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	font-size: 1.2em;
	text-transform: uppercase;
	margin-bottom: 15px;
}
.recipe-line {
	flex: auto;
	height: 1px;
	border-bottom: 1px solid #e0e0e0;
	margin-left: 15px;
}
.recipe-times .recipe-line {
	margin-left: 0;
}
.recipe-times__container {
	display: flex;
	padding: 5px;
	margin: 5px 0;
}
.recipe-times__item {
	flex: 1;
	display: flex;
	flex-direction: column;
	text-align: center;
}
.recipe-times__item .label {
	text-transform: uppercase;
	opacity: 0.6;
}

Now my pizza recipe looks much more delicious and beautiful:

The pizza recipe on the WordPress website

You can see the full-sized recipe here.

Tutorial Video

We made a video for this tutorial, you may want to watch it:

Last Words

As you can see, creating a recipe with Meta Box plugin isn’t difficult. We just need to create custom post types, custom fields and display them on the front end, everything is quite easy.

Depending on the needs of the website owner, the recipe will have other items. You just need to add or remove custom fields accordingly to fit your requirements. I hope your food blog will be successful. If you have any questions about custom fields and meta boxes, leave a comment or join the Meta Box Users Facebook group!

In addition, some WordPress themes display your food and recipes beautifully and attractively, discover them here.

Pick Tools for Your Case Studies

Other case studies you might be interested in

  1. Create A Dynamic Landing Page in WordPress Using Custom Field
  2. How to Create ACF Flexible Content Field with Meta Box
  3. How to Create a Product Page using Meta Box Plugin
  4. How to Add Related Posts to WordPress Using Meta Box
  5. How to Create a Classified Ads Website using Meta Box
  6. Create Posts Series in WordPress Using Meta Box
  7. How to Add Guest Author in WordPress using Meta Box (Part 1)
  8. How to Add Guest Author in WordPress using Meta Box (Part 2)
  9. Create Dynamic Favicon in WordPress using Meta Box plugin
  10. How to Build a Hotel Booking Website Using Meta Box - P1
  11. How to Build a Hotel Booking Website Using Meta Box - P2 - Booking Page in Backend
  12. How to Build a Hotel Booking Website Using Meta Box – P3 – Booking Page for Customer
  13. How to Create an FAQs Page Using Meta Box
  14. How to Manually Reorder Posts with Meta Box
  15. How to Add Custom JavaScript Actions Using Button Field with Meta Box
  16. Display a User List On the Frontend with Meta Box
  17. How to Build a Hotel Booking Website Using Meta Box - P4 - Booking Management Page
  18. How to Filter Posts by Custom Fields and Custom Taxonomies on Archive Pages
  19. How to Use Custom HTML Field to Output Beautiful Texts or Output Custom CSS
  20. Create an OTA Website Like Booking.com with Meta Box Plugin - P1: Create a Page to Introduce Hotel Rooms
  21. Create an OTA Website Like Booking.com with Meta Box Plugin - P2: Create Filters on the Archive Page
  22. Create an OTA Website Like Booking.com with Meta Box Plugin - P3: Create Filters for Single Hotel Pages
  23. How to Add Custom Fields to Display Banners using Meta Box Plugin
  24. How to Create Download Buttons Using Custom Fields with Meta Box Plugin
  25. How to Create a Recipe with Meta Box Plugin
  26. How to Create an Auto-Updated Cheat Sheet in WordPress
  27. How to Create Online Admission Form for School or University
  28. How to Create Online Reservation Form for Restaurants using Meta Box

Leave a Reply

Your email address will not be published. Required fields are marked *