我目前正在尝试了解设置 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