Support

Account

Home Forums Front-end Issues Execute shortcode on text area Instructions

Solved

Execute shortcode on text area Instructions

  • Hi good day to all developers,
    I really need your help i need to execute the shortcode on the text area of the instructions field please see my screenshot i really need your help.

    Screenshot

  • use the acf/prepare_field filter and run shortcoded on the field instructions. https://www.advancedcustomfields.com/resources/acf-prepare_field/

    
    add_filter('acf/prepare_field/name=example_field', 'my_acf_prepare_field');
    function my_acf_prepare_field($field) {
      $field['instructions'] = do_shortcode($field['instructions']);
      return $field;
    }
    
  • Thank you for the response i will try that one

  • Not working by the way the instructions field is the default in acf see my screen shot on my post please help me

  • Are you trying to make the shortcode work when editing the field in ACF or when someone else is editing a post and adding content to the field?

    I tested this and it works perfectly on my test field named “some_shortcode” when I added [some_shortcode] to the acf instuctions field.

    
    add_filter('acf/prepare_field/name=some_shortcode', 'do_sortcode_in_field_instructions');
    function do_sortcode_in_field_instructions($field) {
    	$field['instructions'] = do_shortcode($field['instructions']);
      return $field;
    }
    
    add_shortcode('some_shortcode', 'do_some_shortcode');
    function do_some_shortcode() {
    	return 'this is result from the shortcode';
    }
    
Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Execute shortcode on text area Instructions’ is closed to new replies.