Reputation: 818
I need to add fields with php in two pages (in advanced custom fields plugin , wordpress)
Here is my try :
acf_add_local_field_group(array (
'key' => 'songs_options',
'title' => 'songs options',
'fields' => array (
array (
'key' => 'field_1',
'label' => 'test title',
'name' => 'test_field',
'type' => 'text',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => 'IN',
'value' => array( 'songs', 'videos'), // i need a code like this line
),
)
),
));
Upvotes: 1
Views: 1461
Reputation: 449
You should use the ==
operator with the locations, and add every location as a different array under 'location':
register_field_group(array (
'key' => 'songs_options',
'title' => 'songs options',
'fields' => array (
array (
'key' => 'field_1',
'label' => 'test title',
'name' => 'test_field',
'type' => 'text',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'songs',
),
),
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'videos',
),
),
),
));
Upvotes: 2