我目前正试图绕过设置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
答案 0 :(得分:0)
对于初学者,您的register_settings('option_group','option_name);
名称不应与我team_details_group
以及team_details_options
等名称相同。
然后在
之后的表单内做settings_fields('team_details_group')
<form method=post action=options.php>
紧接着$options = get_option('team_details_options')
然后在输入字段name属性中使用team_details_options
来保存任何数据,即:
<input type="text" name="team_details_options[memberName]" />
请告诉我这是否有帮助,或者您需要更多信息。