Hello there,
I would like to be able to display featured posts only by using a checkbox to switch it on / off.
My checkbox custom field only has one choice: Display.
The custom field name is: feature_on_home
How can I modify the following query to include this so that only posts in which the checkbox is ticked will be displayed?
<?php $loop = new WP_Query(
array(
'post_type' => 'news',
'posts_per_page' => 3 )
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
// Content
<?php endwhile; ?>
Thanks for all and any help.
Spencer
something like
<?php $loop = new WP_Query(
array(
'post_type' => 'news',
'posts_per_page' => 3,
'meta_key' => 'feature_on_home',
'meta_value' => '1' )
);
?>
Hi,
Thanks for getting back – oddly, this now displays nothing now.
I have ticked three items to test, but nowt.
Any idea?
Thanks a million,
Spencer
you said checkbox so I was assuming a true false field, is that correct? if not change the meta_value to the value that’s saved by your checkbox field