acf_trash_field()
acf_trash_field
Trashes a field from the database.
Hooks from the function
Returns
true|false. True if field was trashed.
Usage
acf_trash_field( $id );
- $id((int|string))
- The field ID, key or name.
Changelog
| Since 5.0.0 | Introduced. |
acf_trash_field() acf trash field code ACF 6.8.8
function acf_trash_field( $id = 0 ) {
// Get the field.
$field = acf_get_field( $id );
// Bail early if field was not found.
if ( ! $field || ! $field['ID'] ) {
return false;
}
// Trash post.
wp_trash_post( $field['ID'], true );
/**
* Fires immediately after a field has been trashed.
*
* @date 12/02/2014
* @since 5.0.0
*
* @param array $field The field array.
*/
do_action( 'acf/trash_field', $field );
// Return true.
return true;
}