I would like to return all the option that I registered under a specific group id.

Is there a way to do this?

  • 1
    What do you mean group id? – Howdy_McGee Jun 15 '17 at 0:51
  • 1
    I don't understand why this was closed. I found this Q&A with a search and it's completely clear to me, and should be to anyone who works with the Settings API. Edited question. The provided answer should be accepted as it does accurately answers the question. – TonyG Dec 17 '17 at 22:09

I 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

  • and if the global is not set? every time you need to use a global you are not initializing yourself, or 100% sure when and how it was initialized, you are most likely doing something wrong. If settings are registered only on admin side, this might generate errors on the front end – Mark Kaplun Jun 15 '17 at 7:15
  • @MarkKaplun you are right this doesn't work for front end. – Bikash Waiba Jun 15 '17 at 7:32
  • That's ok, I only need it to work on the backend – Top-Bot Jun 15 '17 at 10:46
  • I think this is a good answer to the question and it should be flagged as Accepted. I've been looking for this info myself and it's very difficult to find. In the WP core, the register_settings() function has this line: $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. – TonyG Dec 17 '17 at 22:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.