The customize_previewable_devices WordPress PHP filter allows you to modify the available devices for previewing in the Customizer.
Usage
add_filter('customize_previewable_devices', 'your_custom_function');
function your_custom_function($devices) {
// Your custom code here
return $devices;
}
Parameters
$devices(array): List of devices with labels and default settings.
More information
See WordPress Developer Resources: customize_previewable_devices
Examples
Add a new device for previewing
Add a new device called “Smartwatch” to the Customizer for previewing.
add_filter('customize_previewable_devices', 'add_smartwatch_preview_device');
function add_smartwatch_preview_device($devices) {
$devices['smartwatch'] = array(
'label' => __('Smartwatch', 'your-theme'),
'default' => false,
);
return $devices;
}
Remove a specific device from previewing
Remove the “Tablet” device from the Customizer preview.
add_filter('customize_previewable_devices', 'remove_tablet_preview_device');
function remove_tablet_preview_device($devices) {
unset($devices['tablet']);
return $devices;
}
Change the label of an existing device
Change the label of the “Mobile” device to “Smartphone”.
add_filter('customize_previewable_devices', 'change_mobile_device_label');
function change_mobile_device_label($devices) {
$devices['mobile']['label'] = __('Smartphone', 'your-theme');
return $devices;
}
Set a new device as the default preview device
Set the “Tablet” device as the default preview device in the Customizer.
add_filter('customize_previewable_devices', 'set_tablet_as_default_device');
function set_tablet_as_default_device($devices) {
$devices['tablet']['default'] = true;
$devices['mobile']['default'] = false;
return $devices;
}
Reorder the devices in the Customizer preview
Change the order of devices in the Customizer preview to Mobile, Desktop, Tablet.
add_filter('customize_previewable_devices', 'reorder_preview_devices');
function reorder_preview_devices($devices) {
$new_order = array(
'mobile' => $devices['mobile'],
'desktop' => $devices['desktop'],
'tablet' => $devices['tablet'],
);
return $new_order;
}