Home › Forums › ACF PRO › get_sub_field_object select labels › Reply To: get_sub_field_object select labels
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.