Advanced Views Docs
Live PlaygroundDownload PluginGet PRO
  • 💡Help Centre
  • ⚡Getting Started
    • Introduction
      • Key Aspects
      • Creating Your First View
      • Creating Your First Card
      • Plugin Terms
      • Plugin Interface
        • Field Options
    • Installation
      • Advanced Views Lite
      • Advanced Views Pro
      • Comparison Table
      • Upgrading from Lite to Pro
    • Supported data vendors
    • Starter theme
  • 🌟Display Content
    • WordPress
      • Post
      • Taxonomy terms
      • User
      • Comments
      • Menus
    • WooCommerce Product
    • Meta fields
      • Basic fields
        • Number
      • Content fields
        • Image
        • File
        • WYSIWYG
        • oEmbed
        • Gallery
      • Choice fields
        • Select/checkbox/radio
        • True / False
      • Relationship fields
        • Link
        • Post_object
        • Page Link
        • Relationship
        • Taxonomy
        • User
      • Advanced fields
        • Google Map
        • Google Map Multiple Markers
        • ACF OpenStreetMap Field
        • Date/time picker
      • Layout fields
        • Group (Pro)
        • Repeater (Pro)
        • Flexible (Pro)
    • Object fields
    • Custom Data (Pro)
    • Custom Gutenberg Blocks (Pro)
    • Mount Points (Pro)
    • Front-end assets management (Pro)
  • 🦸‍♂️Query Content
    • Basic Filters
    • Meta Filters (Pro)
      • Current Post
      • Comparison
      • Dynamic Injection
    • Taxonomy Filters (Pro)
    • Pagination (Pro)
    • Custom Data (Pro)
  • 🏆Shortcode Attributes
    • Common Arguments
    • View Shortcode
    • Card Shortcode
  • 🧙‍♂️Templates
    • Customizing the Template
    • Template engines
      • Twig
      • Blade
    • CSS & JS
      • BEM Methodology
      • WordPress Interactivity API
    • File system storage
    • Pre-built components
    • Reusable components library (Pro)
    • Live reload
    • Multilingual
    • Custom Ajax & Rest API (Pro)
  • ☕Guides
    • Display Custom Post Type (CPT) on another post
    • Display Employees (CPT) of a Company (CPT)
    • Display Nested Repeater Fields
    • Map Marker from ACF Image
    • Display all CPT items on a single map
  • 🛠️Tools
    • Export/Import
    • Demo Import
    • Settings
    • Preview
  • 🏹Troubleshooting
    • Compatibility
    • Report a bug
    • Payment Issues
    • Lite Support (Forum)
    • Pro Support
  • ⚙️Customization
    • Filters and Hooks
      • View
      • Card
    • Suggest a feature
    • Performance
Powered by GitBook
On this page
  • How to use it
  • Displaying items as a Grid
  • Displaying items in a Slider
  • Nested repeaters
  • Advanced usage
  • Picking up a random row
  • Custom items sorting

Was this helpful?

  1. Display Content
  2. Meta fields
  3. Layout fields

Repeater (Pro)

PreviousGroup (Pro)NextFlexible (Pro)

Last updated 8 months ago

Was this helpful?

The Repeater field type (e.g. ) provides a neat solution for repeating content – think slides, team members, CTA tiles and alike.

ACF offers a dedicated field type called Repeater, whereas MetaBox provides the Group field exclusively. However, enabling the 'clonable' setting of the MetaGroup effectively transforms it into a repeater.

Repeater acts as a parent to a set of sub fields which can be repeated again and again. What makes this field type so special is its versatility. Any kind of field can be used within a Repeater, and there are no limits to the number of repeats either (Unless defined in the field settings).

How to use it

Select your repeater field Group, then select the repeater Field from the dropdown.

Enable Slider, by selecting an optional library from the list.

Switch to the Sub Fields tab, and assign the Group sub fields.

Click on the Update button to save your View.

Copy the shortcode into the post, page or CPT where you want to display the fields.

Fill out the fields as required, then click Publish or Update to save your page or post.

Visit your page to see the result.

Displaying items as a Grid

#view__repeater {
 display: grid;
 grid-template-columns: 1fr;
 gap: 20px;
}

@media screen and (min-width:992px) {
#view__repeater {
  grid-template-columns: repeat(2, 1fr);
 }
}

Displaying items in a Slider

After adding the repeater field to the target View, change the 'Enable Slider' option to 'Splide v4' and press the Save button. It'll automatically change the field markup to incorporate the necessary classes, and add the default JS instance:

var repeater_inner = this.querySelector('.pro-fields__repeater-inner');
if (repeater_inner) {
	/* https://splidejs.com/guides/options/ */
	new Splide(repeater_inner, {
		type: 'loop',
		perPage: 1,
		perMove: 1,
	}).mount();
}

Nested repeaters

AVF supports nested repeaters with no restrictions on the depth of nesting. To display a nested repeater, follow these steps:

  1. Create the Parent View:

    • Go to the Views section and create a new 'Parent' View.

    • Select the target repeater field in the Fields tab and save the View.

  2. Create the Child View:

    • Create another View, this will be the 'Child' View.

    • In the 'Parent Group' field of this View, choose the target repeater field that is nested within the Parent View and save the View.

  3. Configure the Parent View:

    • Open the 'Parent' View.

    • In the repeater field settings of the Parent View, select the 'Child' View you just created from the 'View' setting and save the Parent View.

That’s it! You can now use the 'Parent' View wherever needed, and it will display both the outer repeater fields and the nested inner repeater. You can further customize the template and add CSS/JS as usual. Note that the 'Child' View is designated for inner usage only and cannot be used directly.

To add another depth level, simply repeat the steps outlined above, treating the 'Child' View as the new parent for the next level of nesting.

Advanced usage

Picking up a random row

{% set randomItem = random(repeater.value) %}
{# todo work with the item as usually: randomItem.subfield.value #}

Custom items sorting

{% for item in repeater.value|sort((a, b) => a.year <=> b.year) %}
{# todo print item fields #}
{% endfor %}

To turn it into Descending order, just put the b to the left side (and a to the right).

You can turn any repeater into Grid, using the , by adding the following to the CSS code field of your View:

AVF comes with a , so you can easily turn the repeater items into a slider.

You can customize it according to your needs, using any available .

This process is also described in the .

Using the , you can pickup a random row:

Using the , you can sort the array by any subfield. The code example below sorts the repeater items by the year subfield in Ascending order:

🌟
CSS grid feature
set of pre-configured JS libraries
Splide options
Display Nested Repeater Fields Guide
random Twig function
sort Twig filter
ACF Repeater field