Remove extra p tags

User
remove extra tag from acf editor field
Assistant
To remove extra “ tags automatically added by WordPress when using ACF (Advanced Custom Fields) WYSIWYG (TinyMCE) editor fields, you can disable the automatic formatting (`wpautop`) by using the `acf/format_value` filter.

### ✅ Option 1: Disable auto “ on specific ACF field

If you want to target **a specific field**, use:

add_filter('acf/format_value/name=your_field_name', 'my_acf_remove_wpautop', 10, 3);
function my_acf_remove_wpautop($value, $post_id, $field) {
    return wpautop($value, false); // disables extra <p> tags
}

Replace `your_field_name` with your actual ACF field name.

### ✅ Option 2: Disable auto “ on all WYSIWYG fields

If you want to apply this **globally to all WYSIWYG fields**, use:

add_filter('acf/format_value/type=wysiwyg', 'my_acf_remove_all_wpautop', 10, 3);
function my_acf_remove_all_wpautop($value, $post_id, $field) {
    return wpautop($value, false); // second parameter false disables wpautop
}

### ✅ Option 3: Completely disable formatting (raw content)
If you want to return the raw content **without any automatic formatting**, just return the value as-is:

add_filter('acf/format_value/type=wysiwyg', 'my_acf_return_raw', 10, 3);
function my_acf_return_raw($value, $post_id, $field) {
    return $value; // no formatting at all
}

Let me know if you’re using ACF blocks or flexible content – the setup can vary slightly in those contexts.

Leave a Comment

Your email address will not be published. Required fields are marked *