Black Friday 2025
Meta Box

How to Show the Featured Restaurants Section - P2 - Using Meta Box and Bricks

In the next part of this series, we’re going to go through several manipulations to know how to show the featured restaurants section on the homepage using Meta Box and Bricks.

This is the section that I made as an example:

Video Version

Before Getting Started

This section will display only the restaurants which are featured. To do it, we will create a field to manually choose which restaurant is featured. Each restaurant is a post of a custom post type.

In addition to the basic information of the restaurant such as the name and photo as the title and featured image of the post, it may include some other information such as the voucher, address and logo. This extra information will be saved in separated custom fields.

So, I recommend using Meta Box AIO, which includes the framework and all extensions, such as:

This section will be built in Bricks. So, make sure that you activate Bricks theme on your site.

Create a Custom Post Type

Go to Meta Box > Post Types > Add New to create a new post type. After publishing, we’ll have a new Restaurants menu in the Admin Dashboard.

create post type

Then, let’s create custom fields in the following step.

Create Custom Fields

Go to Meta Box > Custom Fields to create fields. Here are all the fields:

Create custom fields

To select and display which restaurant is featured on the frontend, I choose Switch field so that users can change the selection button.

The Switch field is to select which restaurant is featured on the homepage.

This field will display as a button and has two status. The Off status will indicate that you do not want to recommend the restaurant. Otherwise, the On status will let us know that you want to showcase it.

If you want to feature the restaurant, just turn on the button

I’ll show the values of this field in the admin column to see whether the restaurant is featured or not by turning on the button like in the image below. This setting is available only when you have the MB Admin Columns extension from Meta Box.

The restaurant is featured when you have MB Admin Columns

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

Set location to apply the fields to the Restaurant post type.

When editing any post in the Restaurants post type, you’ll see all created custom fields.

All the created custom fields

Create the Section on Homepage

Go to Pages, then edit Homepage with Bricks.

Create the Section on the Homepage

Add a new Section element to contain all the restaurant’s information.

Add a Section element

Then, add a Heading element to name the section.

Add a Heading element

Set the Condition to Display Featured Posts

To get all the posts from the post type, we can use the Posts element. We also can use this element in this practice. It supports adding conditions to choose which posts you want to show. However, we’ll use another way to do it by using a div tag in this tutorial. So, add a Div element.

With this Div element, you can get posts with conditions as well. But, to get each information of the posts, you can add different elements then easily style each one with more options of settings instead of coding.

Set the Condition to display featured posts

Since each restaurant is a post of a custom post type, switch to enable the Use the query loop option and set the query to get the wanted posts and post type.

Enable Use the query loop option and set the query to get the wanted posts and post type

Set the query to get the wanted posts and post type

We’ll display the featured restaurants only, so scroll down to find the Meta Query section and enter the meta key as the ID of the field named Feature the Restaurant.

Go to Meta Query section then enter the meta key as the ID of the field to display the featured restaurants only

Since this is a Switch field with 2 options: On or Off. Corresponding to these 2 options, their values are 1 and 0. So if you want to choose the featured posts which you turned on the button, enter 1 corresponding to the On option in the Meta Value.

Then, choose the Compare and Type options as Equal and Numeric, respectively.

Choose the Compare and Type options as Equal and Numeric respectively

That’s all for the condition. Next, we’ll display all the information of the restaurants.

Display the Restaurants Information

To display the image of the restaurant, add the Image element.

Since these images are the featured image of the post, choose the select dynamic data button and find the Featured Image option in the Post section.

Display the Restaurants information

Then, all the restaurants’ images have been obtained.

All the restaurants' images have been obtained

For the Logo of the restaurant, also add the Image element > select dynamic data button and search for the field.

Add the Image element and select dynamic data to get the Logo of the restaurant

For the name of the restaurant means the title of the post, add the Post Title element. After that, all the names of the restaurant will display correspondingly.

Add the Post Title element to get the name of the restaurant to

For the Voucher information, add the Basic Text element and also use the select dynamic data button and find the corresponding fields. Here, it’s Voucher.

Add the Basic Text element for the Voucher information

To display the Address information, do the same.

Do the same to display Address

Now, all the information is now shown.

All the information is now shown

Style the Section

For styling, go to the Bricks visual builder and style the element you want.

In the event that you want to have more advanced styling for the Voucher information, just add a CSS class for it. Then, go to the Style tab > CSS and add some code in the Custom CSS section.

Style the Section

Add some CSS code

On the Homepage, the featured restaurants section will display beautifully.

The final result after styling

Last Words

Using custom fields is a brilliant way to create a condition for displaying posts. If you see this practice is helpful, try it out and share the result with us. Or, if you want to suggest any idea, feel free to leave a comment. Thanks for reading!

Leave a Reply

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