Hey Elliot – Thanks for the response, and that was my first thought as well. However this is happening on a 20in screen at full width, where there is plenty of room. I will clone the site into staging and downgrade to see if the problem was there before the last upgrade, but this is something that I only recently noticed.
these are repeaters within repeaters
Hey Elliot, thanks for this push. Since I am using a checkbox which will pass an array instead of a single value, i used this:
// vars
$includedCrossSells = get_field('ssm_cross_sells_list', $id);
$crossSellTitle = get_sub_field('ssm_cross_sell_title', 'option');
// find matching row
if ( have_rows('ssm_cross_sells', 'option') ) {
while ( have_rows('ssm_cross_sells', 'option' ) ) {
the_row();
if ( in_array( (get_sub_field('ssm_cross_sell_title', 'option')), $includedCrossSells ) ) {
echo '<a href="' . get_sub_field('ssm_cross_sell_link', 'option') . '"><img src="' . get_sub_field('ssm_cross_sell_image', 'option') . '"</></a>';
echo '<p><a href="' . get_sub_field('ssm_cross_sell_link', 'option') . '">' . get_sub_field('ssm_cross_sell_title', 'option') . '</a></p>';
}
}
}
This works, but what is interesting is that when i pass $crossSellTitle as a variable which takes get_sub_field('ssm_cross_sell_title', 'option'); as a value, instead of using the full get_sub_field('ssm_cross_sell_title', 'option'); it doesn’t work. Can you spot why that is?
Thank you so much
i had a typo in my code from your earlier response. it was correct! Thanks. Rich
Yes, ssm_featured_content is my repeater field.
The code above returns:
Array
Array
There are two items in the repeater, so two arrays are being returned.
Thanks for helping me through this, and sorry if this is becoming a PITA for you.
Hey Jonathan –
I gave that a shot but it isn’t working, and I think it’s because I am trying to access this data from within a foreach loop, like so:
<div class="news-container">
<?php $news = get_field('ssm_featured_content'); ?>
<?php foreach ($news as $item) { ?>
<?php $postObject = get_sub_field('ssm_featured_page'); ?>
<?php echo $postObject->$post_title; ?>
<?php } ?>
</div>
<!-- end .news-container -->
I tried to adjust as follows, but I am not sure how the code should look:
<?php echo $item[$postObject->$post_title]; ?>
but that didn’t seem to be correct either. I’m just not sure how to handle this.
Rich
Thanks for the quick response. This appears to be what I was looking for…turns out I forgot to use “sub” in get_sub_field, like an idiot
Rich
yup that worked. thank you. -Rich
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.