Support

Account

Home Forums General Issues How to use a shortcode with ACF? Reply To: How to use a shortcode with ACF?

  • The problem lies with the Custom Field / Shortcode combo you’ve crafted. The other fields are working fine and are not part of the issue.

    Let’s assume stadium_slider is a ‘Gallery Field’, look at the Gallery Field Docs here.

    The bottom example pretty much shows exactly what you’re attempting.

    <?php 
    $image_ids = get_field('gallery', false, false);
    $shortcode = '[gallery ids="' . implode(',', $image_ids) . '"]';
    echo do_shortcode( $shortcode );
    ?>

    Use this example code, replace get_field('gallery', false, false); with get_field('stadium_slider', false, false);.
    This should dump a basic WordPress gallery with the images that have been selected in the back end.

    Now we need Owl Carousel to take over. According to the owl-carousel plugin, there should be a setting to override the default galleries with it instead, take a look in it’s settings for something that sounds like this.

    Find this setting and you are away.

    A good help would be to turn on debug mode if you haven’t already in wp-config. If the code is already there, set it to true like so.

    define( 'WP_DEBUG', true );

    Hope this helps!