@speakincode That did the trick! Thanks so much for your help, I appreciate it!
That’s great, thank you!
Here’s what I get with var_dump(get_sub_field( 'product_type' ));
array(2) { [“value”]=> string(14) “fireplace_wood” [“label”]=> string(16) “Fireplace – Wood” }
I changed get_field('product_type')
to get_sub_field('product_type')
, but still no.
Looking for any similar examples, I came across some that sparked a thought, that since the Return Value for the Radio Button is Both (Array), maybe I need to use variables like this, but it also didn’t work:
<?php if ( have_rows( 'specifications' ) ) : ?>
<?php while ( have_rows( 'specifications' ) ) : the_row(); ?>
<?php
$product_type_array = get_sub_field( 'product_type' );
$product_type_value = $product_type_array['value'];
$product_type_label = $product_type_array['label']; ?>
<?php if( get_sub_field($product_type_value) == 'fireplace_wood' ) { ?>
<?php if ( have_rows( 'wood_fireplace_specs' ) ) : ?>
<?php while ( have_rows( 'wood_fireplace_specs' ) ) : the_row(); ?>
<ul>
<li><?php the_sub_field( 'heating_capacity_wf' ); ?> sq ft</li>
<li><?php the_sub_field( 'maximum_burn_time_wf' ); ?> hrs</li>
<li><?php the_sub_field( 'log_length_wf' ); ?>in</li>
<li><?php the_sub_field( 'maximum_btus_wf' ); ?></li>
<li><?php the_sub_field( 'emissions_wf' ); ?> grams per hr</li>
<li><?php the_sub_field( 'efficiency_wf' ); ?>%</li>
<li><?php the_sub_field( 'firebox_wf' ); ?> cubic ft</li>
<li><?php the_sub_field( 'viewing_glass_wf' ); ?> sq in</li>
</ul>
<?php endwhile; ?>
<?php endif; ?>
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>
I tried simplifying it to just test the conditional checking for Product Type, but this also doesn’t work.
<?php if ( have_rows( 'specifications' ) ) : ?>
<?php while ( have_rows( 'specifications' ) ) : the_row(); ?>
<?php
$product_type_array = get_sub_field( 'product_type' );
$product_type_value = $product_type_array['value'];
$product_type_label = $product_type_array['label']; ?>
<?php if( get_sub_field($product_type_value) == 'fireplace_wood' ) { ?>
<p>Test</p>
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>
So I’m still at a loss on what to do here.
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.