Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress query to show all posts with custom radio field set to "1" - not working?
    text
    copied!<p>I have a custom post type named testimonials, and I have a few custom fields within it. One of the custom fields is a radio button option, it asks "is this a homepage featured testimonial?" and has 2 options, yes or no, and the values for both are 1 and 2.</p> <p>I am trying to only show the posts where the value was set to "1" (set to yes) for that radio button option but it doesn't seem to work.</p> <p>I have all of the post custom field info showing on the page, but it's also showing the posts with "2" as the value. I also have it showing the value for the radio button in the post, and they are set properyl to "1" or "2." I'm just having issues with the query to only show ones with the value "1."</p> <p>Here is my code: </p> <pre><code>&lt;?php // args $args = array( 'post_type' =&gt; 'testimonials', 'posts_per_page' =&gt; 4, 'order' =&gt; 'ASC', 'meta_query' =&gt; array( 'key' =&gt; 'homepage-testimonial', 'value' =&gt; '1' ) ); // get results $testimonial_query = new WP_Query( $args ); // The Loop if( $testimonial_query-&gt;have_posts() ): $count = 0; while ( $testimonial_query-&gt;have_posts() ) : $testimonial_query-&gt;the_post(); $count &lt;= 2; $count++; $testimonial_homepage_option = types_render_field("homepage-testimonial", array("raw"=&gt;"true")); $testimonial_img = types_render_field("testimonial-image", array("output"=&gt;"html")); $testimonial_name = types_render_field("testimonial-name", array("raw"=&gt;"true")); $testimonial_para = types_render_field("testimonial-para", array("raw"=&gt;"true")); ?&gt; &lt;div class="grey-cta-item"&gt; &lt;?php echo $testimonial_homepage_option; ?&gt; &lt;?php echo $testimonial_img; ?&gt; &lt;?php echo $testimonial_name; ?&gt; &lt;p class="yellow-title-caps"&gt; &lt;?php the_title() ?&gt; &lt;/p&gt; &lt;?php echo $testimonial_para; ?&gt; &lt;/div&gt; &lt;?php endwhile; ?&gt; &lt;?php endif; ?&gt; &lt;?php wp_reset_query(); // Restore global post data stomped by the_post(). ?&gt; </code></pre> <p>I have also tried these ways to make it show properly:</p> <pre><code>'homepage-testimonial' =&gt; 1 </code></pre> <p>and</p> <pre><code>'meta_query' =&gt; array( array( 'key' =&gt; 'homepage-testimonial', 'value' =&gt; '1' )) </code></pre> <p>See anything I'm doing wrong?</p> <p>I used the plugin "Types" to create my custom fields if that maybe makes a difference.</p> <p>Really need the help! Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload