Support

Account

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.