Application Example (ACF)

The best part of custom fields application is to use them in post/page and product templates.

Let’s check on how to add and apply custom fields to templates on the example of single product template.

Please note: this is just one example. The application scenarios of custom fields and templates are unlimited.

Assume, we have created and applied some single product template (learn more on how to use single product templates) to the products in our shop and now we need to add an additional custom youtube video to all products to show product specific video on product page (not in the product gallery, but on some different location in product page). To do this, proceed as follows:

STEP 1: Adding new “Video” field to products

1

Install and activate ACF plugin

2

Go to ACF and add new field group

3

Define the group name – in this example we know, that we need additional field for products, so let’s name it “Additional product fields” and click on “Save Changes”

4

Now we need to define the location for this field group. Scroll down to “Settings” and choose “post type is equal to Product”

click on “Save Changes”

5

Start adding new field. We need to add “Video” field to the products. In the “field type” choose “oEmbed” , enter the field label name “video” and specify the video size

No other settings are needed, just click on “Save” again. click on “Save Changes”

6

Now go to edit any product, scroll down and you will see this new custom fields group, where you can enter the youtube link to your product video

STEP 2: Inserting new “Video” field in product template

1

Open the product template you have applied to this product

2

Start editing the template in page builder. Select the “Custom Fields” element and drag’n’drop it to the section where you wish to place your product video in this template


3

In “Source” select the ACF field group we have added for products – “Additional product fields”

4

In “Select Custom Field” select the “Video” field and disable “Label”

5

Click on update and close the editor

6

Now return to the product and preview it. As you can see, the product video specified on this product page has been successfully applied:

That’s all. In the same way you can add as many custom fields to your post/product (and insert it in the post/product template) as you wish.


You can learn more about how to use custom fields in grids and grid filters in following chapters: