I would like to return all the option that I registered under a specific group id.
Is there a way to do this?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI don't think there is a function. But you can create your own like this
function function_name(){
global $new_whitelist_options;
// array of option names
$option_names = $new_whitelist_options[ 'your_option_group_name' ];
// your_option_group_name is in register_setting( 'your_option_group_name', $option_name, $sanitize_callback );
foreach ($option_names as $option_name) {
echo get_option($option_name).'<br>';
}
}
See: here
EDIT:
$new_whitelist_options was renamed to $new_allowed_options since 5.5.0.
view change log here
$new_whitelist_options[ $option_group ][] = $option_name;
In agreement with others, the provided Answer could have included a check for the existence and non-null value of $new_whitelist_options but that's PHP housekeeping that seems outside the scope of this Q&A.
group id
?