Home › Forums › Front-end Issues › Query from radio button field not working
Hi,
I’ve set up a radio field for a custom post type called Column. The 2 values you can select are left and right.
I have this query working:
<?php
$args = array(
'numberposts' => -1,
'post_type' => 'work',
'meta_query' => array(
array(
'key' => 'column',
'value' => 'left'
)
)
);
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>
<ul>
<?php while( $the_query->have_posts() ) : $the_query->the_post();
$workColor = get_field('work_colour');
?>
<li class="block" style="background-color: <?php echo $workColor; ?>;">
<a href="<?php the_permalink(); ?>" data-color="<?php echo $workColor; ?>">
<div class="inner">
<img src="http://duo.local/wp-content/uploads/2017/10/nsconcrete.jpg" alt="">
</div>
</a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); ?>
This query is working and only showing the posts that are ‘left’ selected.
When I change the meta value from ‘left’ to ‘right’ it doesn’t show anything yet there are posts that are selected with right.
'meta_query' => array(
array(
'key' => 'column',
'value' => 'left'
)
)
Any help with this would be greatly appreciated.
Thanks

There is only one thing I can think of that would cause it to work for left and not right and that is that the value being saved is not “right”. The first thing I’d do is double check the values I’ve set up for the radio field.
Haha jesus. Typical typo in the backend. It was:
right:: Right instead of right : Right
I did set this up on the last day of the working year after a few beers. Thanks John.
The topic ‘Query from radio button field not working’ is closed to new replies.
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.