0

私は現在、正直に言うと少し苦労している設定APIについて頭を悩ませようとしています。

私が抱えている問題は、サブページでフォームを送信すると、options.php ページに移動することです。

これまでの私のコードは次のとおりです

function setup_theme_admin_menus() {  


add_menu_page('Theme settings', 'SMate Options', 'manage_options',   
    'theme_settings', 'theme_settings_page');  

add_submenu_page('theme_settings',   
    'Front Page Elements', 'Front Page', 'manage_options',   
    'theme_settings_fp', 'theme_front_page_settings'); 

    add_submenu_page(
    'theme_settings',   
    'Team Option', 
    'Team Option', 
    'manage_options',   
    'theme_team_options', 
    'theme_team_settings_fn'
    );  
}


add_action('admin_init', 'initialize_theme_options'); 


function initialize_theme_options(){

register_setting('team_details', 'team_details' );

add_settings_section( 
    'member1',         
    'MEMBER 1',                  
    'theme_settings_fn', 
    'theme_team_options'
); 

add_settings_field(   
    't1',                  
    'Name',                 
    'text_fn',                       
    'theme_settings_team',
    'member1'
); 
add_settings_field(   
    'jt1',        
    'Job',      
    'text_fn',    
    'theme_settings_team', 
    'member1' 
);  
add_settings_field(   
    'lt1',
    'Description',  
    'longtext_fn',  
    'theme_settings_team',
    'member1' 
);
}

add_action('admin_init', 'initialize_theme_options');


function theme_team_settings_fn() { 


?>  

    <div class="wrap">  


        <div id="icon-themes" class="icon32"></div>  
        <h2>Sandbox Theme Options</h2>  


        <?php print_r('team_details');
         settings_errors(); ?>


        <form method="post" action="options.php">  
            <?php do_settings_sections('theme_team_options'); ?> 
            <?php submit_button(); ?>  
        </form>  

    </div><!-- /.wrap -->  
<?php  


}

私はレンガの壁にぶつかったようで、すべてのチュートリアルは add_theme_page を使用して通過しているように見えるので、どんな助けも大歓迎です

4

1 に答える 1

0

For starters your register_settings('option_group','option_name); shouldn't be the same name I would do team_details_group and maybe team_details_options, etc.

Then do settings_fields('team_details_group') right inside the form after the

<form method=post action=options.php>

followed immediately by $options = get_option('team_details_options')

then use team_details_options to inside the input fields name attribute to save any data i.e:

<input type="text" name="team_details_options[memberName]" />

Let me know if this helps or you need more information.

于 2013-03-08T17:28:10.370 に答える