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!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.