Support

Account

Home Forums Add-ons Flexible Content Field Shortcode inside flexible field

Helping

Shortcode inside flexible field

    • erdd

    • June 21, 2021 at 5:17 am

    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 🙂 )

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.