ACF: radio button (conditional content) in flexible content template part

[ad_1]

I’m not sure what I’m doing wrong and my Google skills are failing me today…

I have a Flexible Content group set up with six sections, all called in the main single.php template in template parts. One section shows images. All fine so far. All I want to do is have a radio button for landscape or portrait, so one can be selected and output a landscape custom size image or a portrait one.

This works fine on another custom template on the site:

<?php if( get_sub_field(‘orientation’) == ‘portrait’): ?>

<?php echo wp_get_attachment_image( $image, ‘portrait’ ); ?>

<?php elseif ( get_sub_field(‘orientation’) == ‘landscape’ ): ?>

<?php echo wp_get_attachment_image( $image, ‘hero’ ); ?>

<?php endif; ?>

but will not work within the template part. I’m driving myself mad with passing variables to the template part, and set_query_var() and lots of things I don’t understand…

This is very boring I know, but does anyone have any ideas?!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer