Struggling to get the format right for the PHP in this do_shortcode embed using variables from Advanced Custom Fields plugin. I think I’ve tried every variation on ., ‘, and “. After reading every resource I could find I’m still no closer.
<?php
$address = get_field('cong_streetaddress');
$city = get_field('cong_city');
$province = get_field('cong_province');
$postalcode = get_field('cong_postalcode');
echo do_shortcode('[pw_map address="'" . $address . " . " . $city . " . " . $province . " . " . $postalcode . "'" width="100%" height="200px"]');
?>
Doing it with just one variable, like so echo do_shortcode('[pw_map address="'. $postalcode . '" width="100%" height="200px"]');
works fine.
Your syntax is broken, the quote marks do not match. Try to separate data from the shortcode template, and use
sprintf()
:Thatâs much easier to read, and it is harder to create syntax errors. 🙂