Champion! That fixed the issue! Thanks! Sorry for all the replies – we got there eventually! If there are any further issues I will post entire code blocks next time!
One quick question, is your advancedcustomfields.com/my-account/ a custom built area? Is it woocommerce with a custom theme?
Thanks again.
Hi Elliot, sorry i mixed around my responses and was providing a non-specific example. With regards to the field group code, here is the code i’m using for this:
if (have_rows('class_menu') ) : ?>
<ul class="class-menu">
<?php while(have_rows('class_menu') ): the_row();
$class_select = (get_sub_field_object('menu_class'));
$class = get_sub_field('menu_class');
$label = ($class_select['choices'][$class]);
$link = get_sub_field('menu_link'); ?>
<li class="<?php echo $class; ?>"><a href="<?php echo $link; ?>"><?php echo $label; ?></a></li>
<?php endwhile; ?>
</ul>
It might get a little confusing, but this works when reverted back to 4.3.8 – is it possible that the database upgrade didn’t work properly? I’m working on a localhost if that helps.
I have reverted back to 4.3.8 for now, using the method above the labels are output properly. I think I will have to wait before upgrading.
Is there any other information I can provide? Is it wise/acceptable to use the get_sub_field instead of the have rows?
When I print_r($object) from the above example, nothing at all is displayed. It’s like the object doesn’t return anything. So the result is:
<pre></pre>
However, I noticed I have another of these loops where get_sub_field_object function appears to beworking, but it’s not in the have rows function.
if (get_sub_field('class_title') ) :
$title_select = (get_sub_field_object('class_title'));
$title_class = get_sub_field('class_title');
$title = ($title_select['choices'][$title_class]);
echo '<h2 class="' . $title_class . ' desktop"><a href="' . $title_class . '">' . $title . '</a></h2>';
echo '<h2 class="' . $title_class . ' mobile">' . $title . '</h2>';
endif;
This is displaying the correct values and labels. print_r(title_select); gives the full array.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.