Advertisement
MikkoDC

Kahua Accordion

Jan 5th, 2024
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. <?php $image_accordion = get_field('accordion_main_image');
  2. if($image_accordion){ echo "Mikko"; } ?>
  3. <?php if( have_rows( 'accordion' ) ): $counter = 0 ?>
  4. <div class="row left-right direction--<?php echo $direction; ?>">
  5. <div class="col col-12 col-md-7">
  6. <div class="image-container animate--<?php echo $direction; ?>">
  7. <?php
  8. if( !empty( $image ) ): ?>
  9. <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
  10. <?php endif; ?>
  11. <?php
  12.  
  13. echo wp_get_attachment_image( $image, 'large' ); ?>
  14. </div>
  15. </div>
  16. <div class="col col-12 col-md-5">
  17. <div class="text-container">
  18. <div class="accordion-items accordion-items__light">
  19. <?php
  20. //note that $direction is available from module-left_right
  21. while( have_rows( 'accordion' ) ):
  22. the_row();
  23. ?>
  24. <div class="accordion-item">
  25. <div class="accordion-heading <?php if( $counter == 0 ) { ?> active<?php } ?>"><?php the_sub_field('sub_heading'); ?></div>
  26. <div class="accordion-content" style="<?php if( $counter == 0 ) { ?> display:block;<?php } ?>">
  27. <h4><?php the_sub_field('main_heading'); ?></h4>
  28. <p><?php the_sub_field('accordion_content'); ?></p>
  29. <?php $link = get_sub_field('button');
  30. if( $link ):
  31. $link_url = $link['url'];
  32. $link_title = $link['title'];
  33. $link_target = $link['target'] ? $link['target'] : '_self';
  34. ?>
  35. <div class="accordion-cta">
  36. <a href="<?php echo $link_url; ?>" target="<?php echo $link_target; ?>" class="button-secondary"><?php echo $link_title; ?></a>
  37. </div>
  38. <?php endif; ?>
  39. </div>
  40. </div>
  41. <?php $counter++; endwhile; ?>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <?php endif; ?>
  47. <script>
  48. jQuery(function() {
  49. jQuery(".accordion-items").on("click", ".accordion-heading", function () {
  50.  
  51. jQuery(this).toggleClass("active").next().slideToggle();
  52.  
  53. jQuery(".accordion-content").not(jQuery(this).next()).slideUp(300);
  54. jQuery(this).parent().siblings().find(".accordion-heading").removeClass("active");
  55. });
  56.  
  57. });
  58. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement