Can I use the different settings sections over different pages using the save options group?


I registered one options group with few different options sections. Each section is meant for different page.

register_setting(                       //
        'mhp_options',                  // Options group
        'mhp_plugin_options',           // Database option
        'mhp_plugin_options_validate'   // The sanitization callback,

// Manage Menu section
add_settings_section(                   //
        $mhp_manage_menu_section,   // Unique identifier for the settings section
        __('Manage Menu Settings', 'mhp'),  // Section title
        '__return_false',               // Section callback (we don't want anything)
        $mhp_manage_menu_section            // Menu slug
        __('Home Page Layout Settings', 'mhp'),     

Then each page is using

settings_fields( 'mhp_options' ); 
do_settings_sections( $mhp_manage_menu_section);

so the other page is using

settings_fields( 'mhp_options' ); 
do_settings_sections( $mhp_home_page_layout_settings_section);

but it looks like on save only current section is saved in the options table. What ever was already there is deleted.

Do I have to create new options group for each page or is there any other solution?

, , Radek 1 year 2020-07-27T07:19:22-05:00 0 Answers 54 views 0

Leave an answer