Skip to content

Instantly share code, notes, and snippets.

@oliwa
Created February 4, 2017 10:50
Show Gist options
  • Save oliwa/43fe0951d87872423a99de057dfdc800 to your computer and use it in GitHub Desktop.
Save oliwa/43fe0951d87872423a99de057dfdc800 to your computer and use it in GitHub Desktop.
Show Hide for a repeater field
<?php if( have_rows('show_hide_repeater') ): ?>
<h2><?php the_field('show_hide_repeater_headline'); ?></h2>
<?php while ( have_rows('show_hide_repeater') ) : the_row(); ?>
<div class="open-close">
<a class="infobox-button close" href="#">
<h3 title="Projekt öffnen/schließen"><?php the_sub_field('show_hide_title'); ?></h3>
<span class="more"><i title="Projekt öffnen" class="fa fa-chevron-down"></i></span>
<span class="hide"><i title="Projekt schließen" class="fa fa-chevron-up"></i></span>
</a>
<div class="infobox">
<?php the_sub_field('show_hide_content'); ?>
<?php if(get_sub_field('show_hide_content_link')) : ?>
<p><a class="btn" target="_blank" href="<?php the_sub_field('show_hide_content_link'); ?>">Mehr Infos ...</a></p>
<?php endif; ?>
</div>
</div>
<?php endwhile; endif; ?>
<script>
jQuery(document).ready(function($) {
$('.infobox-button.close').live('click', function() {
$('.infobox-button.open').click();
$('.infobox').slideUp();
$(this).siblings('.infobox').slideDown();
$(this).toggleClass('close open');
return false;
});
$('.infobox-button.open').live('click', function() {
$('.infobox').slideUp();
$(this).toggleClass('close open');
return false;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment