Support

Account

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

Helping

Shortcode inside flexible field

  • 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.