Home › Forums › General Issues › Exporting Fields with Widget Locations › Reply To: Exporting Fields with Widget Locations
The widget should have the same slug (name) on both your dev site and in your new plugin.
Here is some test generated code I exported.
if( function_exists('register_field_group') ):
register_field_group(array (
'key' => 'group_5421d12d3b08c',
'title' => 'User Registration',
'fields' => array (
array (
'key' => 'field_5421d133e4826',
'label' => 'File Upload',
'name' => 'file_upload',
'prefix' => '',
'type' => 'file',
'instructions' => 'Upload a file',
'required' => 1,
'conditional_logic' => 0,
'return_format' => 'array',
'library' => 'uploadedTo',
),
),
'location' => array (
array (
array (
'param' => 'widget',
'operator' => '==',
'value' => 'recent-comments',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
));
endif;
As you can see, this add a “File Upload” to the “recent-comments” widget. recent-comments
is the slug associated with that widget. This location value must match the widget you are trying to target. Make sure you are assigning a slug when you generate the widget. See the codex info on creating widgets for more info.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.