Support

Account

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.