
maybe that works:
<?php
$blubb = '[gallery ids="';
$images = get_field('acf-gallery');
if( $images ):
$counter = 0;
foreach( $images as $image ):
if ( $counter > 0 ) {$blubb .= ',';}
$blubb .= $image['id'];
$counter++;
endforeach;
endif;
$blubb .= '"]';
echo $blubb;
?>

that is good. you see that it works π
the 8 is because you echo $row_count--;
and testimonials_7_testimonial is the field name for the last row.
now use something like that:
$rows = get_post_meta( 348, 'testimonials', false ); // get number of rows, is inside a array
$row_count = $rows[0]; //get row number out of array
$row_count--; // because first row start with 0 not 1 subtract one from row number
$lastrow_content = 'testimonials_'.$row_count.'_testimonial'; //get last row field
$lastrow_head = 'testimonials_'.$row_count.'_testimonial_header'; //get last row field
$end_testimonial_content = get_post_meta( 348, $lastrow_content, true );// get the last row value
$end_testimonial_header = get_post_meta( 348, $lastrow_head, true ); // get the last row value
$last = '<blockquote>' . $end_testimonial_content . '</blockquote><p>' . $end_testimonial_header . '</p>';
echo $last;

to get ids separated by “,” without trailing “,” you could use:
<?php $images = get_field('acf-gallery');
if( $images ):
$counter = 0;
foreach( $images as $image ):
if ( $counter > 0 ) {echo ',';}
echo $image['id'];
$counter++;
endforeach;
endif; ?>

because $rows always have the count of rows you could use:
$rows = get_post_meta( 348, 'testimonials', false ); // get number of rows (8 but in a array)
$row_count = $rows[0]; //get row number out of array (8)
$row_count--; // because first row start with 0 not 1 subtract one from row number (8-1 =7)
//now you could use $row_count to get last row (7)
echo 'testimonials_'.$row_count.'_testimonial'; //you need to replace echo by a variable and use that
Hint:
$rows--; is short form of $rows = $rows-1;
because $rows and better $row_count always have the correct row number you can add/remove rows without problems

probably your end function return 5 (5 rows)
but row 5 use _4_(beause rows start with _0_)
you dont need this line to get subfields:
$rows = get_post_meta( 348, 'testimonials', false ); // get all the rows
but what is inside $rows?
if it is the row-count, or you could get it from it.
than use $rows--; after and you have the number you can use for the last row

One thing i could say is, both the repeater and flexible content fields save their data in this format:
$ParentName_$RowNumber_$ChildName
the values of testimonial for the first and second row are saved into this 2 DB-Fields.
'testimonials_0_testimonial' //for first row
'testimonials_1_testimonial' //for second row
maybe that help.
else: debug $rows => that means: look what inside $rows is.
echo '<pre>';
print_r( $rows);
echo '</pre>';
probably it is not array like you expect (because each subfield has it own db-row)

i am not sure, but i think that this wrapper attributes are for backend only.
with that you can stile backend.
because at frontend you can easy wrap your field for example by a class & by blockquote with code like this:
$my_quotetext = get_field('my_quotetext');
echo '<div class="my_quote">';
echo '<blockquote>';
echo '<p>'.$my_quotetext.'</p>';
echo '</blockquote>';
echo '</div>';
there is no need to add wrapper at backend before

just to get sure:
you have a working single-performance.php, that print out everything you need.
you have a working page-gallery.php with featured image and title that link for now to single-performance.php?
and you wish a link to single-performance.php that only shows the gallery?
if yes, i think this will be the easiest way to solve that would be:
inside page-gallery.php something like that instead of permalink only
add_query_arg( 'gallery_only', 'yes', get_permalink() );
inside your plugin or functions.php add it to the public query variables
function add_custom_query_var( $vars ){
$vars[] = "gallery_only";
return $vars;
}
add_filter( 'query_vars', 'add_custom_query_var' );
inside single-performance.php get value that you pass when it come from page-gallery.php
$my_gallery_only = get_query_var( 'gallery_only' );
use after that if ($my_gallery_only == 'yes')
to switch between your normal-all and gallery-only view
hope that this is what you need and that it works for you

what did you mean with:
Help me find a script that plugin Gallery.
did you mean something like: simple lightbox?
if yes look at my post inside this thread to get a sample that should work.
primary you need :
if ( function_exists('slb_activate') ){
$content = slb_activate($content);
}
where $content is output of gallery before you echo it echo.
but you could add any js that provide the popup-functionality when you know how to structure your output and how to apply the needed js.

i dont understand where your problem is:
what are you using? what code did you have? what are you trying to do?

please wrap your code inside code tags (button at top of textfield, where you write forum post)
and show the whole loop (at least the if get_row_layout part. of course you can/should reduce fields/layouts to dont get to long code. but we need to understand what you did wrong)
did your code look somehow like this? :
<?php
// check if the flexible content field has rows of data
if( have_rows('flexible_content_field_name') ):
// loop through the rows of data
while ( have_rows('flexible_content_field_name') ) : the_row();
if( get_row_layout() == 'flexible_content_layout_name' ):
the_sub_field('some_field');
elseif( get_row_layout() == 'other_flexible_content_layout_name' ):
$field = get_sub_field('other_field');
echo $field;
endif;
endwhile;
else :
// no layouts found
endif;
?>

you could use:
$row1 = get_field('counter_repeater_0_counter_number'); //for first row
$row2 = get_field('counter_repeater_1_counter_number'); //for second row
...
echo "<tr><td><p>name:</p></td><td><p>";
echo $row1;
echo "</p></td><tr>";
...
instead of your if-while loop (just add 3+4 row & echo row 2-4 where you wish)

what is your goal?
first should be possible with php without big problems. use something like that:
<div class="quote-section">
<div class="slider4">
<?php if( have_rows('quote_slider') ):
$img_count=1;
while ( have_rows('quote_slider') ) : the_row();
if ($img_count == 1) {
?>
<li class="slide active">
<div class="quote"><?php the_sub_field('quote'); ?></div>
<div class="name"><?php the_sub_field('name'); ?></div>
<div class="image"><img src="<?php the_sub_field('image'); ?>" /></div>
</li>
<?php } else {?>
<li class="slide">
<div class="quote"><?php the_sub_field('quote'); ?></div>
<div class="name"><?php the_sub_field('name'); ?></div>
<div class="image"><img src="<?php the_sub_field('image'); ?>" /></div>
</li>
<?php }
$img_count++; ?>
<?php endwhile;
else : endif; ?>
</div>
</div>
second is/shouldbe part of your slider js, and there i could not help you

field_name of Name field? => if it is name try to change it to something else.
did you have same problem? => if you change Layout of repeater to block or row

as far as i know:
because you replace standard genesis loop with your own loop, you need to add schema at your own again.
& please when you post code:
wrap code with code tags (at top over textfield where you write your forum-post-entry you have code mark your code and press that button, than it will be formatted like mine, much better for readability. do that before first submit.)
(if) you have forgotten that:
please edit your post, copy-paste code form original and replace existing not formatted code, mark new inserted code and click on code. save/submit forum post again
edit: thanks for edit your previous post, looks much better now.
better readable than your first post with code, for example.
with one exception somehow it add wrong ‘single_quote’ and “double_quote” β<div class=β instead of '<div class="`

could you try this (use have_rows and a wile loop instead of your foreach loop) :
<aside class="widget">
<?php
if( have_rows('tool_section_links') ):
echo '<h2>Tools</h2>';
echo '<ul>';
while( have_rows('tool_section_links') ): the_row();
$show_desktop = get_sub_field('show_desktop');
$tool_link = get_sub_field('tool_link');
$tool_link_title = get_sub_field('tool_link_title');
if ($show_desktop == 'yes'){
echo '<li class="show-for-large-up"><a href="'.$tool_link.'">'.$tool_link_title.'</a></li>';
} else {
echo '<li><a href="'.$tool_link.'">'.$tool_link_title.'</a></li>';
}
endwhile;
echo '</ul>';
endif;
?>
</aside>
depend on witch fieldtype you use change if ($show_desktop == 'yes') to correct value

the users wonβt be confused as to why they need to add the same image twice if they want it to be the featured image and be in the gallery.
it is just a matter how you label that image-field and what description text you set, and that it is after the gallery-field.
also user don’t had to re-upload image, he should just “re-select” a already uploaded image. if you only show images uploaded to that post (for gallery and for featured image) it should be no problem and not confuse,
if gallery dont have 50+ images it will be also relative easy to use.
but that my humble opinion, if you dont think so i have no problem with that

i dont know if true/false has Problem with repeater.
try if it works when you dont use == true, to ckeck if checked like that:
if( get_sub_field ('show_desktop') ) {
...
} else {
...
}
if this also dont work, you could try to replace true/false with a
Radio Button or Check-Box field with value “yes” (and “no” when you use radio-button) and use code like that.
$show_desktop = get_sub_field ('show_desktop');
if ($show_desktop == 'yes'){
...
} else {
...
}
of course you can replace yes/no with any value you wish when you use radio-button/check-box, just adapt code above

it depends on:
the most easy thing is for sure to have a additional Image field (not required) where user can select that image. (optional create a filter or savepost action to set WP featured image to that field)
also easy would be to use the first image of the gallery when additional yes/no field after gallery is set to true.
a little more difficult would be to get a random, or the last image of the gallery.
possible but probably not failsave is to let user select or type the image countnumber. and use that if possible, else use first image.
if you are good at coding:
create a additional fieldtype that create a drop-down with image and filename out of the gallery (something that works like relationship but for gallery) probably done with js

hi, try if this works: (sort by date-field instead of header)
foreach( $repeater as $key => $row ) {
$thedate = $row['your_date_field'];
$column_id[ $key ] = strtotime($thedate);
}
array_multisort( $column_id, SORT_DESC, $repeater );
foreach( $repeater as $row ){
i assume date field is part of the repeater.
replace your_date_field with name of the date field. (part of my code)

did you get a output when you use something like this? :
<?php
// check if the repeater field has rows of data
if( have_rows('address_details') ):
// loop through the rows of data
while ( have_rows('address_details') ) : the_row();
// display a sub field value
the_sub_field('address');
the_sub_field('author');
endwhile;
else :
// no rows found
endif;
?>

would this work? :
foreach( $repeater as $row ) {
$testimonial_p = $row['testimonial'];
$testimonial_h2 = $row['testimonial_header'];
echo '<article><div class="entry-content testimonial">';
echo '<p>' . $testimonial_p . '</p>';
echo '<h2>' . $testimonial_h2 . '</h2>';
echo '</div></article>';
}

add this or something similar to functions.php or your plugin
<?php add_image_size( 'my_thumb', '160', '390', true );?>
after that you can use your created size inside your layout-loop
<?php
$images = get_field('gallery');
if( $images ): ?>
<ul>
<?php foreach( $images as $image ): ?>
<li>
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['sizes']['my_thumb']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<p><?php echo $image['caption']; ?></p>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

@jtotheroc how should ACF know which Layout it should start with?
flexible content isn’t like Repeater where you have always the same fields.
and if you use just 1 Layout, why you use flexible field and not a repeater?
there the min-row count row are visible (if you set min row to 3, repeater start with 3 rows)

you cant use foreach as with the same variable π
but your real problem is probably here:
'key' => 'section_contents', //this is the post relationship field, which is in a repeater subfield of 'toc_section'
subfield of repeater
if you have luck change this too and it works:
key' => 'toc_section_%_section_contents',
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.