Hello,
+1 for this question, i am looking for the solution too…
+1 for this
ACF Pro with WPML translation of $field[‘label’] needed.
Hello, this solved my problem:
<?php
if( have_rows('repeater_field_name') )
{
$field_key = "repeater_field_number";
$field = get_field_object($field_key);
foreach($field['value'] as $value)
{
if(!empty($value['repeater_subfield_name']))
{
$not_empty = true;
break;
}
}
if($not_empty == true)
{
echo '<h2>' . $field['label'] . '</h2>';
}
echo '<ul>';
while ( have_rows('repeater_field_name') )
{
the_row();
$subfield = get_sub_field('repeater_subfield_name');
if( !empty($subfield) )
{
echo '<li>' . $subfield . '</li>';
}
}
echo '</ul>';
}
?>
Uff,
i tried, but no success.
I’ll try to explain it on example again. The result is:
<h2>Title</h2>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
If the “li” (= repeater sub field) not exists, list not exists, “h2” (= repeater field label) is not displayed. i will be greatfull for any help with this lines of code.
Hello,
“Title” is written in code but it is the same as label of repeater field.
Sorry,
title is hidden even if the subfields are not empty. Any ideas?
Thanks a lot.
finally i found this great tutorial about sql queries for ACF:
http://www.advancedcustomfields.com/resources/tutorials/querying-the-database-for-repeater-sub-field-values/
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.