Share:
Facebook
Twitter

ACF – Disable text tab in post editor for frontend form

In ACF we can easily disable the Text tab for any new field, it’s just an option under the field settings. However, how to do that for the default content field when the post content is loaded using the function acf_form()?
There are some places on the internet when people are trying to solve this but without any success so we decided to show you how to disable the Text tab when usinf the function acf_form() with the parameter post_content enabled.
Note: we tested this with ACF PRO version 6.2.6.1.

If you go to the plugin’s file“/advanced-custom-fields-pro/includes/fields/class-acf-field-wysiwyg.php” line 206 we have this:


we just need to find a way to set “$field[‘tabs’] == ‘visual'”. In order to do that we must use the filter acf/prepare_field, acf/prepare_field/name={$name} more exactly.
Copy this code and paste into your child-theme’s function.php file.
add_filter(‘acf/prepare_field/name=_post_content’, function($field){       
        $field[‘tabs’]=’visual’;
        return$field;
});

Share:
Facebook
Twitter

Subscribe to Newsletter

Stay on top of your child’s education and school life