
-
AuthorPosts
-
May 30, 2025 at 11:58 pm #1484893
i have 2 columns that contain a persons headshot (using the image block > styled > circle) and their bio (using the text block) underneath. this fits nicely in our page width & wraps well for mobile. but i’ve now been informed that there will be more than 2 people (pic & bio).
is there a way to use these colums > image > text in some sort of horizontal slider or accordion kind of thing? where 2 columns remain visible but there’d be a hint that a 3rd column (or more) is there for the user to click on for the columns to slide left, now showing the 2nd & 3rd columns (with the 1st column hinted at left like the 3rd column was at right).
the closest block i’ve found in Enfold is the “Content Slider”, but it’s not obvious enough that there are more columns to explore. the arrows seem small & obscure, and there’s no hint (faded partial view of the 3rd slide) of more content to click the arrows for; and when clicked, it removes the first 2 slides altogether to make room for the 3rd, instead of leaving the 2nd in the 1st position with the 3rd in the 2nd position. does that make sense?
i suspect this is too detailed of a desire & beyond the bounds of Enfold and the Layerslider it includes. so i thought i’d ask in case anyone knows of any 3rd party plugin that might do this before/while i start exploring.
May 31, 2025 at 4:00 pm #1484899Hey syberknight-tb,
Unfortunately, we don’t have an element that will achieve this for you in the theme, while there are many plugins that may work for you, when I check some of them they don’t quite match, but if you spend more time testing each one you may find one.
I was able to create something that may work for you using javascript and HTML in a shortcode, on mobile it shows 1 1/2 team member cards with prev & next arrows and loop when you click to the end:
on tablet it shows 2 1/2 cards:
and on desktop it shows 3 1/2 cards:
As is it holds 8 cards, you can add more or have less, you will need to edit the HTML to add your images and text, hopefully you will be able to do this:
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor, If you are not using a child theme you could use the WP Code plugin then add a new snippet, in the top right corner use the PHP snippet as the code type:
and ensure that it is activated, then add the code below and save.function team_carousel_shortcode() { ob_start(); ?> <div class="carousel-container"> <button id="prevBtn">←</button> <div class="carousel"> <div class="carousel-track"> <!-- START: Team Members --> <div class="card"> <img src="/people-2-2-300x300.jpg" alt="Member 1"><p>Member 1<br>A short bio for the team member</p></div> <div class="card"> <img src="/people-2-2-300x300.jpg" alt="Member 2"><p>Member 2<br>A short bio for the team member</p></div> <div class="card"> <img src="/people-2-2-300x300.jpg" alt="Member 3"><p>Member 3<br>A short bio for the team member</p></div> <div class="card"> <img src="/people-2-2-300x300.jpg" alt="Member 4"><p>Member 4<br>A short bio for the team member</p></div> <div class="card"> <img src="/people-2-2-300x300.jpg" alt="Member 5"><p>Member 5<br>A short bio for the team member</p></div> <div class="card"> <img src="/people-2-2-300x300.jpg" alt="Member 6"><p>Member 6<br>A short bio for the team member</p></div> <div class="card"> <img src="/people-2-2-300x300.jpg" alt="Member 7"><p>Member 7<br>A short bio for the team member</p></div> <div class="card"> <img src="/people-2-2-300x300.jpg" alt="Member 8"><p>Member 8<br>A short bio for the team member</p></div> <!-- END: Team Members --> </div> </div> <button id="nextBtn">→</button> </div> <style> .carousel-container { position: relative; width: 80%; overflow: visible; margin: auto; } .carousel { overflow: hidden; width: 100%; } .carousel-track { display: flex; transition: transform 0.5s ease-in-out; } .card { box-sizing: border-box; padding: 10px; background: #e8e8e8; margin: 5px; border-radius: 8px; text-align: center; box-shadow: 0 4px 10px rgba(0,0,0,0.1); } @media only screen and (max-width: 767px) { .card { flex: 0 0 62%; } } @media only screen and (min-width: 768px) and (max-width: 1800px) { .card { flex: 0 0 38%; } } @media only screen and (min-width: 1801px) { .card { flex: 0 0 28%; } } .card p { color: #000; } .card img { width: 100%; height: auto; object-fit: cover; border-radius: 100%; } #nextBtn, #prevBtn { position: absolute; top: 50%; transform: translateY(-50%); color: #000; border: 2px solid #000; padding: 10px; cursor: pointer; z-index: 10; } #prevBtn { left: -50px; } #nextBtn { right: -50px; } </style> <script> document.addEventListener('DOMContentLoaded', function () { const track = document.querySelector('.carousel-track'); const cards = document.querySelectorAll('.card'); const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); let currentIndex = 0; let cardWidth = cards[0].offsetWidth + 20; function updateCarousel() { const shift = currentIndex * cardWidth; track.style.transform =
translateX(-${shift}px)
; } function moveToNext() { currentIndex++; if (currentIndex >= cards.length) { currentIndex = 0; } updateCarousel(); } function moveToPrev() { currentIndex--; if (currentIndex < 0) { currentIndex = cards.length - 1; } updateCarousel(); } nextBtn.addEventListener('click', moveToNext); prevBtn.addEventListener('click', moveToPrev); window.addEventListener('resize', () => { cardWidth = cards[0].offsetWidth + 20; updateCarousel(); }); }); </script> <?php return do_shortcode(ob_get_clean()); } add_shortcode('team_carousel', 'team_carousel_shortcode');Then add this shortcode in a code block element on your page:
[team_carousel]
Feel free to adjust the colors in the css in the code.Best regards,
MikeMay 31, 2025 at 4:04 pm #1484900Hi,
Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.Best regards,
MikeJune 2, 2025 at 11:55 pm #1484991WOW Mike! thank you for all that!!
i will give it a try mid-week & report back on how it goes :-)June 4, 2025 at 9:05 pm #1485087June 5, 2025 at 8:25 pm #1485121hi Mike. i guess you can close this thread.
i thank you SO much for your time & effort. it is greatly appreciated!
one thing, for reference, it wasn’t working for me right-away. after digging in & comparing to your live example, i discovered your example has back-ticks around
translateX(-${shift}px)
(which seem to be striped away from this post) which the above code didn’t. after adding that, it worked as expected.✌🏼
June 5, 2025 at 9:29 pm #1485123Hi,
Glad that this worked for you, I’m not sure whytranslateX(-${shift}px)
was stripped from your test, but it’s in the code above. Nonetheless, glad that it is working for you now.
If you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Column Accordion/Slider-like ability?’ is closed to new replies.