Is it possible to get a list of options for a specific options group?

Because the group is not the same as a category or taxonomy. It’s used to determine where that settings UI control is displayed in the WP Admin area.

e.g. the value general is for the general settings admin screen, not because it’s a general options group.

Until the introduction of the settings endpoint and the REST API, the primary purpose of this function was to let WordPress know about an option so that it would know to save that option, and as a part of the settings GUI API.

Most commonly it would be combined with a call to add_settings_field, this would tell WP that to add a field for a setting with a callback to display it, and which page it will appear on.

Then, on that page, would be a do_settings_sections call that’s given the page, e.g. 'general', and calls to do_settings_fields that would take a page and a section.

e.g. adding a setting to the general settings page:

// Registering the field
function wpdocs_add_option_field_to_general_admin_page() {
 
    register_setting( 'general', 'Field_Name_To_Add' );
 
    add_settings_field( 
        'field_id-to-add', 
        'Field Name To Display', 
        'wpdocs_setting_callback_function', //Function to Call
        'general', 
        'default', 
        array( 
            'id' => 'field_id-to-add', 
            'option_name' => 'Field_Name_To_Add'
        )
    );
}
 
// Adding options to registered field
add_action( 'admin_menu', 'wpdocs_add_option_field_to_general_admin_page' ); // CallBack Function
 
function wpdocs_setting_callback_function( $val ) {
    $id = $val['id'];
    $option_name = $val['option_name'];
    ?>
    <input 
        type="tel" //this can be any HTML input type: date, number, text etc.
        name="<?php echo esc_attr( $option_name ) ?>"
        id="<?php echo esc_attr( $id ) ?>"
        value="<?php echo esc_attr( get_option( $option_name ) ) ?>" // Displays the value stored in DB
    /> 
    <?php
}

Note here that there is no “group” of options called general, and it only exists in certain circumstances ( you wouldn’t add a settings control on the frontend, only in WP Admin ).

So this isn’t something you can use to provide structure for options in the database.

More recently register_setting has been used to define default values for options, and as a way to expose options in the REST API.


The closest to what you were hoping for though, is get_registered_settings:

https://developer.wordpress.org/reference/functions/get_registered_settings/

This will give you the main registered settings array. You would then need to loop through each setting, filtering out the ones that don’t match your desired group.

Note that this is not a way to get a list of all stored options, as not all options are registered, and it isn’t commonplace in most plugins and themes yet. It also won’t show transients etc for the same reason.