How can I set a default value for a PostObject? The field is created as follows:
$this->addField( [
‘key’ => ‘field_647348f1324af’,
‘label’ => ‘Kooperationspartner’,
‘name’ => ‘referral_partners’,
‘prefix’ => ”,
‘type’ => ‘post_object’,
‘instructions’ => “”,
‘required’ => 0,
‘conditional_logic’ => 0,
‘wrapper’ => [
‘width’ => ”,
‘class’ => ”,
‘id’ => ”,
],
‘post_type’ => [
0 => ‘referrer_partner’,
],
‘taxonomy’ => ”,
‘allow_null’ => 1,
‘multiple’ => 1,
‘return_format’ => ‘id’,
‘ui’ => 1,
] );
If you then create a new article (post), a value must already be assigned.
Hi @patjaboo
You can take a look at the acf/load_field filter that makes it possible to modify field settings before the field is loaded. You can then create some logic to set a value if the field does not contain a value.
https://www.advancedcustomfields.com/resources/acf-load_field/