I have a simple shortcode in functions.php:
add_shortcode ('getAppID', 'get_current_page_url');
function get_current_page_url() {
if(isset($_GET['appID'])){
$appID = $_GET['appID'];
$fullAppID = '?appID=' . $appID;
return $fullAppID;
}
}
which I want to trigger in a flexible ACF field with
[getAppID]
But it doesn’t work. It works perfectly in a NON-ACF field. The documentation for how to do use shortcode in a flexible or repeater field does not exist.
I’m using Contact 7 forms in this way. I have a flexible content field I’m using as a page builder.
I added my shortcode to a text field schedule_a_demo_form
like this;
[contact-form-7 id="xxx" title="Schedule A Demo"]
In my template I do this;
$scheduleADemoForm = get_sub_field('schedule_a_demo_form');
echo do_shortcode($scheduleADemoForm);
Also, to prevent users from altering the shortcode in the text field I added a class admin-readonly
to the wrapper and in my admin-styles.css
added this style;
.admin-readonly {
pointer-events: none;
}
This prevents them from accessing the input (unless they know how to use developer tools that is 🙂 )