Home › Forums › General Issues › Using field data in shortcode › Reply To: Using field data in shortcode
Hey @Tintin,
You’ll want to create a variable for your string then use a concatenated string -> http://php.net/manual/en/language.operators.string.php.
$idcode = get_field('id_code');
echo do_shortcode('[shortcode id="'.$idcode.'"]');
You could also skip the variable all together and just use the get_field function inline.
echo do_shortcode('[shortcode id="'.get_field('id_code').'"]');
Hope that helps. 🙂
EDIT: Added inline function option.
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.