Home › Forums › Add-ons › Repeater Field › Create default rows for repeater › Reply To: Create default rows for repeater
Hi @yavisht
I think your code is good enough. You can also move it so the repeater is updated before you’re trying to show it like this:
if( !have_rows('quick_links', 'user_' . $user_id) ){
$updated_value = array(
array("icon"=>"fa-align-justify","title"=>"Link 1","link"=>"http://www.hotmail.com"),
array("icon"=>"fa-align-justify","title"=>"Link 2","link"=>"http://www.google.com"),
array("icon"=>"fa-align-justify","title"=>"Link 3","link"=>"http://www.yahoo.com"),
);
update_field('quick_links', $updated_value , 'user_' . $user_id);
}
if( have_rows('quick_links', 'user_' . $user_id) ):
// loop through the rows of data
while ( have_rows('quick_links', 'user_' . $user_id) ) : the_row();
// Testing field output
the_sub_field('icon', 'user_' . $user_id);
echo "<br />";
the_sub_field('title', 'user_' . $user_id);
echo "<br />";
the_sub_field('link', 'user_' . $user_id);
echo "<br />";
echo "<br />";
endwhile;
endif;
I hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.