Home › Forums › Add-ons › Repeater Field › Bootstrap Modal Pop › Reply To: Bootstrap Modal Pop
I have a similar issue, but I’m trying to separate several arrays on a page while showing collapsible repeaters (arrow icon to expand additional information). I’m using Bootstrap cards to show the custom posts in a grid of cards. It was also coded as a shortcode.
The issue I’m having is that only one of my expandable card sections is working but not the ones with the arrays. This page works: http://dev-une-online-testing.pantheonsite.io/about/about-owl/
This page does not work. I’m not seeing the icon to expand the repeater content: http://dev-une-online-testing.pantheonsite.io/about/about-owl/academic-programs/
Is it a counting issue? or are the arrays nested incorrectly? The working snippet is the last section in the <?php } else { ?> section. Any ideas? I’ve been banging my head on this for days!
<?php
function owl_shortcode($atts) {
ob_start();
extract(shortcode_atts (array(
'category' => '',
'name' => '',
'orderby' => 'title'
), $atts));
if ($category) {
$cats = explode(",", $category);
$array = array();
for ($i = 0; $i < count($cats); ++$i) {
$array[] = get_category_by_slug($cats[$i])->term_id;
}
$custom_query = new WP_Query( array(
'category__and' => $array,
'post_type' => 'owl',
'orderby' => $orderby,
'order' => 'ASC',
'posts_per_page' => -1
));
}
else {
$custom_query = new WP_Query( array(
'post_type' => 'owl',
'orderby' => $orderby,
'order' => 'ASC',
'posts_per_page' => -1
));
}
?>
<div class="row">
<ul class="none">
<?php if ( $custom_query->have_posts() ): while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
<div class="col-sm-6">
<li class="card containFloat">
<?php //image ?>
<div class="circle">
<?php $image = get_field('image');
if( !empty($image) ):
$size = 'thumbnail';
$thumb = $image['sizes'][ $size ]; ?>
<img src="<?php echo $thumb; ?>" alt="<?php echo $image['alt']; ?>" />
<?php else: ?>
<img src="https://online.une.edu/wp-content/uploads/2018/06/blank-female-profile.jpg" alt="" height="150px" width="150px"/>
<?php endif; ?>
</div>
<?php if (in_array("program-administrator", $cats) || in_array("program-manager", $cats) || in_array("program-staff", $cats)) { ?>
<div class="containFloat">
<h2 class="margin-top">
<?php the_title(); ?>
<?php if (get_field('degree')) echo ', ' . get_field('degree'); ?>
</h2>
<p><?php the_field('job_title'); ?></p>
<p><i class="fas fa-phone"></i> <?php the_field('phone'); ?> </p>
<p><a href="mailto:<?php the_field('email'); ?>"><i class="fas fa-envelope-open"></i> <?php the_field('email'); ?></a></p>
<br>
</div>
<?php if (in_array("program-administrator", $cats) || in_array("program-manager", $cats)) { ?>
<div class="clearBoth">
<!--- Accordion Expander - Shortcode Test - Program Administrator / Program Manager --->
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php
//$uniqueid = get_sub_field( 'collapser' );
$uniqueid = uniqid('collapser');
$count = 0;
while ( have_rows( 'collapser' ) ) : the_row(); ?>
<div class="panel panel-default listbox">
<div class="panel-heading" role="tab" id="headingTwo">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse-<?php echo esc_attr( $uniqueid ); ?>-<?php echo esc_attr( $count ); ?>" aria-expanded="false">
<?php the_sub_field( 'expand_row') ?>
</a>
</div>
<div id="collapse-<?php echo esc_attr( $uniqueid ); ?>-<?php echo esc_attr( $count ); ?>"
class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<?php if (get_sub_field('description')) { ?>
<div class="panel-text"><b>More info</b><?php the_sub_field('description'); ?></div>
<?php } ?>
<?php if (get_sub_field('education')) { ?>
<div class="panel-text"><b>Education</b><?php the_sub_field('education'); ?></div>
<?php } ?>
<?php if (get_sub_field('expertise')) { ?>
<div class="panel-text"><b>Expertise</b><?php the_sub_field('expertise'); ?></div>
<?php } ?>
<?php if (get_sub_field('experience')) { ?>
<div class="panel-text"><b>Experience</b><?php the_sub_field('experience'); ?></div>
<?php } ?>
<?php if (get_sub_field('research')) { ?>
<div class="panel-text"><b>Research Interests</b><?php the_sub_field('research'); ?></div>
<?php } ?>
<?php if (get_sub_field('publications')) { ?>
<div class="panel-text"><b>Publications</b><?php the_sub_field('publications'); ?></div>
<?php } ?>
<?php if (get_sub_field('bio')) { ?>
<div class="panel-text"><b>Bio</b><?php the_sub_field('bio'); ?></div>
<?php } ?>
</div>
</div>
</div>
<?php $count ++; ?>
<?php endwhile; ?>
</div>
</div>
<?php } ?>
<?php } else { ?>
<div class="containFloat">
<h2><?php the_title(); ?></h2>
<p><?php the_field('job_title'); ?></p>
<p><i class="fas fa-phone"></i> <?php the_field('phone'); ?> </p>
<p><i class="fas fa-envelope-open"></i> <a href="mailto:<?php the_field('email'); ?>"> <?php the_field('email'); ?></a></p><br>
</div>
<!--- Accordion Expander - OWL.php --->
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php
//$uniqueid = get_sub_field( 'collapser' );
$uniqueid = uniqid('collapser');
$count = 0;
while ( have_rows( 'collapser' ) ) : the_row(); ?>
<div class="panel panel-default listbox">
<div class="panel-heading" role="tab" id="headingTwo">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse-<?php echo esc_attr( $uniqueid ); ?>-<?php echo esc_attr( $count ); ?>" aria-expanded="false">
<?php the_sub_field( 'expand_row' ) ?>
</a>
</div>
<div id="collapse-<?php echo esc_attr( $uniqueid ); ?>-<?php echo esc_attr( $count ); ?>"
class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<?php if (get_sub_field('description')) { ?>
<div class="panel-text"><b>More info</b><?php the_sub_field('description'); ?></div>
<?php } ?>
<?php if (get_sub_field('expertise')) { ?>
<div class="panel-text"><b>Expertise</b><?php the_sub_field('expertise'); ?></div>
<?php } ?>
</div>
</div>
</div>
<?php $count ++; ?>
<?php endwhile; ?>
</div>
<!--- End Accordion --->
<?php } ?>
</li>
</div>
<?php endwhile; endif; ?>
</ul>
</div>
<?php
wp_reset_query();
return ob_get_clean();
}
?>
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.