Thank you @kiwicreative for the feedback. Here is more information so you may better see the issue. The below code works except for the contact form shortcode.
First, this is for a Board of Directors page where each board member has their own contact form, i.e., shortcode.
Second, the counter is used for a Bootstrap4 collapse area to hide each members contact form until it is opened upon being clicked.
The below code is working… all but the contact forms (see near bottom of code). I suspect this is because there is no differentiation between each form because the code is using $short over and over again.
Please let me know if you need more information. And thank you!
<?php $count = 1; if( have_rows('directors_and_officers') ): while ( have_rows('directors_and_officers') ) : the_row(); $member = $count++; echo "<div class='officer'><div class='photo'><img src='"; the_sub_field('photo'); echo "' width='300' height='300' alt='Photo of "; the_sub_field('name'); echo "'><h3>"; the_sub_field('name'); echo "</h3><h2>"; the_sub_field('title'); echo "</h2><p>"; the_sub_field('phone'); echo "</p></div><div class='bio'>"; the_sub_field('biography'); echo "<button class='btn btn-primary' type='button' data-toggle='collapse' data-target='#collapse-"; echo $member; echo "' aria-expanded='false' aria-controls='collapse-"; echo $member; echo "'>Contact "; the_sub_field('name'); echo "</button> <div class='collapse' id='collapse-"; echo $member; echo "'> <div class='card card-body'>"; $contactUs = get_field( "contact_form_shortcode" ); $short = $contactUs; echo do_shortcode($short); echo "</div></div></div></div>"; endwhile; else : // no rows found endif; ?> </div><!-- #officers -->
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!
© 2022 Advanced Custom Fields.