Skip to content

Instantly share code, notes, and snippets.

@Bobz-zg
Last active May 21, 2025 04:07
Show Gist options
  • Save Bobz-zg/d43cf16cf60001f6adc334866b8f2f7c to your computer and use it in GitHub Desktop.
Save Bobz-zg/d43cf16cf60001f6adc334866b8f2f7c to your computer and use it in GitHub Desktop.
Set default values for ACF Textarea field in WP Admin
<?php
// No direct access
defined( 'ABSPATH' ) || exit;
/**
* Set default values for ACF Textarea field in WP Admin
*/
add_filter( 'acf/validate_field', function( $field ) {
if ( empty($field['type']) )
return $field;
if ( $field['type'] !== 'textarea' )
return $field;
// Set default values
$field['rows'] = 2;
$field['new_lines'] = 'br';
/**
* Other available options
*
* [ID] => 1
* [key] => field_681ad11eba380
* [label] => {Label will go here}
* [name] => {Field Name will go here}
* [aria-label] =>
* [prefix] =>
* [type] => textarea
* [value] =>
* [menu_order] => 2
* [instructions] =>
* [required] => 0
* [id] =>
* [class] =>
* [conditional_logic] => 0
* [parent] => 1
* [wrapper] => Array
* (
* [width] =>
* [class] =>
* [id] =>
* )
* [default_value] =>
* [maxlength] =>
* [allow_in_bindings] => 0
* [rows] => 2
* [placeholder] =>
* [new_lines] => br
* [_name] =>
* [_valid] => 1
*/
return $field;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment