From the course: WordPress: Advanced Custom Fields

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Displaying the repeater in your theme

Displaying the repeater in your theme - WordPress Tutorial

From the course: WordPress: Advanced Custom Fields

Start my 1-month free trial

Displaying the repeater in your theme

- [Instructor] With our repeater field created, it's time to add it to our theme. This is going to be slightly different than how we added the previous fields because in essence a repeater field is an array of fields. Luckily, if you're familiar with the WordPress loop, the syntax will look very familiar. Open up your code editor to our child theme and then open content dash single dot PHP. We're going to add this code right after the profile description and before the friends field around line 30. First we'll call a function called have_rows. This is a function provided by advanced custom fields to check to see if our repeaters field has any data in it. Our repeated field is named resume, all lower case. That's the field name that will provide. If our repeater field does have rows, we're going to open up a new div with the class resume. Then much like our friends field, we're going to set up a format and use printf to print out each field. So we'll create a new variable called…

Contents