Skip to content
Advertisement

ACF Custom Fields, Custom Post Types and Bootstrap Carousel

I am building a front end using Understrap/Bootstrap and CMS system in WordPress using ACF and custom posts. I am trying to integrate a carousel displaying product images and information taken from a custom post type.

The fields are pulling through but I have an issue with all the carousel-items being active which causes them to overlay each other.

I have seen similar issues when using an ACF repeater field but nothing using post types.

I know the solution is to add a php snippet with $num to control which slides are active but I can’t work out where or how to add the code in the loop.

Code is below, any help, advice or relevant answers appreciated. Thanks

JavaScript

Advertisement

Answer

You have to add counter ($i) and based on slide number – echo active class.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement