Home Forums Add-ons Repeater Field Target first entry


Target first entry

  • Hey! I am currently making a website for a local band and want to display the upcoming gigs on the Gigs page, but also have the next gig show on the homepage.

    For example:

    Feb 5th – Gig title
    Feb 20th – Gig Title
    March – 1st – Gig Title

    These would be on the gigs page.

    Now on the homepage I want to show just the first entry in the repeater field. That being the Feb 5th.

    So which ever entry is first in the list is the one that will show.

    How do I target just the first entry?

    Many thanks

  • You can get the value of the repeater field as an array by doing the following:

    $gig_dates = get_field('gig_dates_repeater');

    At this point $gig_dates is an array of arrays with each sub array representing a single row in the repeater, so to get the first one simply do $gig_dates[0]. This will return another array containing the sub fields of the corresponding row, for example:

        'gig_date' => 'Feb 5th',
        'gig_title' => 'Gig title'

    I hope this helped.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Target first entry’ is closed to new replies.