Home › Forums › General Issues › Loop issue with checkbox › Reply To: Loop issue with checkbox
Hi,
in your example you’re checking the whole array of “featured”. Well, you’re already in the loop, so you’re already just working with a single post – and that post can either have the “featured” field on or off.
If you have the ‘featured’ field as a boolean (true/false), you can just edit your IF line to this:
<?php if(get_field('featured')) { ?>
And if you’re setting this field to something custom, just check it against that value:
<?php if(get_field('featured') == 'custom_value') { ?>
… ad as far as getting only one post (last) – fix your query, you can set “posts_per_page” to -1 to include all of the featured posts.
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.