The get_registered_settings() WordPress PHP function retrieves an array of all registered settings.
Usage
$all_registered_settings = get_registered_settings();
Parameters
- No parameters for this function.
More information
See WordPress Developer Resources: get_registered_settings()
Examples
Display a list of all registered settings
This example retrieves all registered settings and displays them in a list.
$all_registered_settings = get_registered_settings(); echo "<ul>"; foreach($all_registered_settings as $key => $value) { echo "<li><strong>{$key}</strong>: {$value['type']}</li>"; } echo "</ul>";
Get registered settings for a specific group
This example retrieves all registered settings and filters them to show only settings for the ‘reading’ group.
$all_registered_settings = get_registered_settings(); $reading_settings = array_filter($all_registered_settings, function($setting) { return $setting['group'] === 'reading'; }); // Display the filtered settings foreach($reading_settings as $key => $value) { echo "Setting: {$key} - Type: {$value['type']}<br>"; }
Check if a specific setting is registered
This example checks if the ‘blogname’ setting is registered.
$all_registered_settings = get_registered_settings(); if (array_key_exists('blogname', $all_registered_settings)) { echo "The 'blogname' setting is registered."; } else { echo "The 'blogname' setting is not registered."; }
Display all registered settings with their description
This example displays all registered settings with their descriptions.
$all_registered_settings = get_registered_settings(); foreach($all_registered_settings as $key => $value) { echo "<strong>{$key}</strong>: {$value['type']} - {$value['description']}<br>"; }
Get and display registered settings of type ‘string’
This example retrieves all registered settings and filters them to display only settings of type ‘string’.
$all_registered_settings = get_registered_settings(); $string_settings = array_filter($all_registered_settings, function($setting) { return $setting['type'] === 'string'; }); // Display the filtered settings foreach($string_settings as $key => $value) { echo "Setting: {$key} - Type: {$value['type']}<br>"; }