Home › Forums › General Issues › help with checkbox and repeater in custom template › Reply To: help with checkbox and repeater in custom template
Hey @eileen.schmidtke.
You’re on the right track there with the logic, you’re just missing a key function to make the check boxes work as conditional options.
You can find the documentation here: http://www.advancedcustomfields.com/resources/checkbox/
The part you should look at is this:
/*
* Conditional statement (Checkbox rvalue is an array)
*/
if( in_array( 'red', get_field('field_name') ) )
{
//...
}
So for your code would look like this … I’ve cleaned it up and commented it a bit as well 🙂
<aside>
<?php if ( in_category( 'farrell' )) {
$rows = get_field('reimburs_links');
if($rows) {
echo '<h2>Reimbursement Information</h2>';
echo '<ul>';
foreach($rows as $row) {
// If Page is checked, use page link and title
if(in_array('page', $row['type_of_link'])) {
echo '<li><a href=”'.$row['page_link'].'”>'.$row['link_title'].'</a></li>';
}
// If file is checked, use file link and title
if(in_array('file', $row['type_of_link'])) {
echo '<li><a href=”'.$row['file_link'].'”>'.$row['link_title'].'</a></li>';
}
}
echo '</ul>';
}
} ?>
</aside>
Hope that helps.
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.