{"id":904,"date":"2013-02-19T15:08:08","date_gmt":"2013-02-19T04:08:08","guid":{"rendered":"http:\/\/www.advancedcustomfields.com\/?post_type=resource&#038;p=904"},"modified":"2022-10-19T18:12:09","modified_gmt":"2022-10-19T21:12:09","slug":"the_repeater_field","status":"publish","type":"resource","link":"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/","title":{"rendered":"the_repeater_field()"},"content":{"rendered":"<h2>Description<\/h2>\n\n<div class=\"acf-tip\"><i><img decoding=\"async\" src=\"https:\/\/www.advancedcustomfields.com\/wp-content\/themes\/acf\/assets\/images\/ui-icons\/hash.svg\"><\/i> <p>This function is deprecated. Please use the <a href=\"https:\/\/www.advancedcustomfields.com\/resources\/have_rows\/\">have_rows()<\/a> function instead.<\/p>\n<\/div>\n\n<p>This function is used within a while-loop to loop through each row of a repeater field.<\/p>\n\n<p>Unlike <code>have_rows()<\/code>, this function will take a step through the available rows each time it is called, causing undesired results when also used within an if-statment.<\/p>\n\n<h2>Parameters<\/h2>\n\n<pre><code>the_repeater_field( $field_name, $post_id );\n<\/code><\/pre>\n\n<ul>\n<li><code>$field_name<\/code> <em>(string)<\/em>  <em>(Required)<\/em>    The name of the Repeater field to be retrieved. e.g. &#8216;gallery_images&#8217;<\/li>\n<li><code>$post_id<\/code>    <em>(mixed)<\/em>   <em>(Optional)<\/em>    The post ID where the value is saved. Defaults to the current post.<\/li>\n<\/ul>\n\n<h2>Return<\/h2>\n\n<p><em>(bool)<\/em> True if a row exists.<\/p>\n\n<h2>Change Log<\/h2>\n\n<ul>\n<li>Deprecated in version 3.3.4<\/li>\n<li>Added in version 2.0.3<\/li>\n<\/ul>\n\n<h2>Requirements<\/h2>\n\n<ul>\n<li><a href=\"https:\/\/www.advancedcustomfields.com\/add-ons\/repeater-field\/\">Repeater field Add-on<\/a> version 1.0.0 or later.<\/li>\n<\/ul>\n\n<h2>Examples<\/h2>\n\n<h3>Loop through Repeater field<\/h3>\n\n<p>This example demonstrates how to loop through a repeater field called &#8220;gallery_images&#8221;.<\/p>\n\n<pre><code>&lt;?php if( get_field('gallery_images') ): ?&gt;\n    &lt;?php while( the_repeater_field('gallery_images') ): ?&gt;\n        &lt;img src=\"&lt;?php the_sub_field('image'); ?&gt;\" alt=\"&lt;?php the_sub_field('alt'); ?&gt;\" \/&gt;\n    &lt;?php endwhile; ?&gt;\n &lt;?php endif; ?&gt;\n<\/code><\/pre>\n\n<h3>Loop through Repeater field from another post<\/h3>\n\n<p>This example demonstrates looping through a Repeater field from a different post with the ID of 123.<\/p>\n\n<p><em>Note:<\/em> You don&#8217;t need to specify the <code>$post_id<\/code> for any sub field functions.<\/p>\n\n<pre><code>&lt;?php\nif( get_field('repeater_field_name', 123) ) {\n    echo '&lt;ul&gt;';\n    while( the_repeater_field('repeater_field_name', 123) ) {\n        echo '&lt;li&gt;sub_field_1 = ' . get_sub_field('sub_field_1') . ', sub_field_2 = ' . get_sub_field('sub_field_2') .', etc&lt;\/li&gt;';\n    }\n    echo '&lt;\/ul&gt;';\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Loops through rows of a Repeater field.<\/p>","protected":false},"parent":0,"template":"","class_list":["post-904","resource","type-resource","status-publish","hentry","resource-category-deprecated","resource-category-functions"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ACF | the_repeater_field()<\/title>\n<meta name=\"description\" content=\"Loops through rows of a Repeater field.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ACF | the_repeater_field()\" \/>\n<meta property=\"og:description\" content=\"Loops through rows of a Repeater field.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/\" \/>\n<meta property=\"og:site_name\" content=\"ACF\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-19T21:12:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.advancedcustomfields.com\/wp-content\/uploads\/2024\/11\/acf-social-202411.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1350\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@wp_acf\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/resources\\\/the_repeater_field\\\/\",\"url\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/resources\\\/the_repeater_field\\\/\",\"name\":\"ACF | the_repeater_field()\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/#website\"},\"datePublished\":\"2013-02-19T04:08:08+00:00\",\"dateModified\":\"2022-10-19T21:12:09+00:00\",\"description\":\"Loops through rows of a Repeater field.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/resources\\\/the_repeater_field\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.advancedcustomfields.com\\\/resources\\\/the_repeater_field\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/resources\\\/the_repeater_field\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resources\",\"item\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/resources\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"the_repeater_field()\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/#website\",\"url\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/\",\"name\":\"ACF\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.advancedcustomfields.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ACF | the_repeater_field()","description":"Loops through rows of a Repeater field.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/","og_locale":"en_US","og_type":"article","og_title":"ACF | the_repeater_field()","og_description":"Loops through rows of a Repeater field.","og_url":"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/","og_site_name":"ACF","article_modified_time":"2022-10-19T21:12:09+00:00","og_image":[{"width":2400,"height":1350,"url":"https:\/\/www.advancedcustomfields.com\/wp-content\/uploads\/2024\/11\/acf-social-202411.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_site":"@wp_acf","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/","url":"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/","name":"ACF | the_repeater_field()","isPartOf":{"@id":"https:\/\/www.advancedcustomfields.com\/#website"},"datePublished":"2013-02-19T04:08:08+00:00","dateModified":"2022-10-19T21:12:09+00:00","description":"Loops through rows of a Repeater field.","breadcrumb":{"@id":"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.advancedcustomfields.com\/resources\/the_repeater_field\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.advancedcustomfields.com\/"},{"@type":"ListItem","position":2,"name":"Resources","item":"https:\/\/www.advancedcustomfields.com\/resources\/"},{"@type":"ListItem","position":3,"name":"the_repeater_field()"}]},{"@type":"WebSite","@id":"https:\/\/www.advancedcustomfields.com\/#website","url":"https:\/\/www.advancedcustomfields.com\/","name":"ACF","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.advancedcustomfields.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.advancedcustomfields.com\/wp-json\/wp\/v2\/resource\/904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.advancedcustomfields.com\/wp-json\/wp\/v2\/resource"}],"about":[{"href":"https:\/\/www.advancedcustomfields.com\/wp-json\/wp\/v2\/types\/resource"}],"version-history":[{"count":0,"href":"https:\/\/www.advancedcustomfields.com\/wp-json\/wp\/v2\/resource\/904\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.advancedcustomfields.com\/wp-json\/wp\/v2\/media?parent=904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}