With the callback function defined, it’s time to build your template part. In this video, define an ID, grab the block’s alignment class, and then write the HTML and PHP necessary to properly display the block’s content, both on the front end and in the block editor.
- With our call-back function defined … it's time to create the template part. … In our child theme under the template parts folder, … we're going to create a new folder called "block". … And inside that folder we'll create … a new file called … "content-fun-facts.php" … This needs to match the name that we used … when we registered our block. … In our template part, let's start with … an opening P-H-P tag and then we will add … a single line comment called "Block Name: Fun Facts". … The next thing we're going to do … is create a new variable called I-D. … And this will be the I-D that gets … used when the block is rendered. … We'll call that fun dash facts dash, … and then we'll use the block I-D … from the block array that was passed … to our call-back function. … The last piece of set-up we have here … is to create a new variable called "align class". … Since every block in the block editor … can have a different alignment class, … we want to grab that dynamically … and associate it with the block. …
- What are custom fields?
- Creating field groups
- Adding content to fields
- Displaying fields on a child theme
- Creating and displaying repeater fields
- Creating a submission form
- Creating a Gutenberg block with PHP only
- Writing rules for field display
- Organizing fields
- Exporting field groups
Skill Level Advanced
1. Getting Started with ACF
2. Creating Field Groups with ACF
Field types overview3m 48s
3. Displaying Your Fields
4. Working with Data in ACF
5. Creating a Gutenberg Block
6. Cleaning Up the Admin
Next steps1m 13s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.