我无法获取我的选项页面以显示任何添加的输入字段。
add_action( 'admin_menu', 'skd_add_admin_menu' );
add_action( 'admin_init', 'skd_settings_init' );
function skd_add_admin_menu( ) {
add_menu_page( 'skilte-designer', 'Skilte Designer', 'manage_options', 'skilte-designer', 'skilte-designer/skilte-designer-admin.php', plugins_url( '/skilte-designer/img/sign.png' ), 21 );
}
function skd_settings_init( ) {
register_setting( 'pluginPage', 'skd_settings' );
add_settings_section(
'skd_pluginPage_section',
__( 'Your section description', 'wordpress' ),
'skd_settings_section_callback',
'pluginPage'
);
add_settings_field(
'skd_text_field_0',
__( 'Settings field description', 'wordpress' ),
'skd_text_field_0_render',
'pluginPage',
'skd_pluginPage_section'
);
add_settings_field(
'skd_text_field_1',
__( 'Settings field description', 'wordpress' ),
'skd_text_field_1_render',
'pluginPage',
'skd_pluginPage_section'
);
add_settings_field(
'skd_text_field_2',
__( 'Settings field description', 'wordpress' ),
'skd_text_field_2_render',
'pluginPage',
'skd_pluginPage_section'
);
add_settings_field(
'skd_text_field_3',
__( 'Settings field description', 'wordpress' ),
'skd_text_field_3_render',
'pluginPage',
'skd_pluginPage_section'
);
add_settings_field(
'skd_text_field_4',
__( 'Settings field description', 'wordpress' ),
'skd_text_field_4_render',
'pluginPage',
'skd_pluginPage_section'
);
add_settings_field(
'skd_text_field_5',
__( 'Settings field description', 'wordpress' ),
'skd_text_field_5_render',
'pluginPage',
'skd_pluginPage_section'
);
}
function skd_text_field_0_render( ) {
$options = get_option( 'skd_settings' );
?>
<input type='text' name='skd_settings[skd_text_field_0]' value='<?php echo $options['skd_text_field_0']; ?>'>
<?php
}
function skd_text_field_1_render( ) {
$options = get_option( 'skd_settings' );
?>
<input type='text' name='skd_settings[skd_text_field_1]' value='<?php echo $options['skd_text_field_1']; ?>'>
<?php
}
function skd_text_field_2_render( ) {
$options = get_option( 'skd_settings' );
?>
<input type='text' name='skd_settings[skd_text_field_2]' value='<?php echo $options['skd_text_field_2']; ?>'>
<?php
}
function skd_text_field_3_render( ) {
$options = get_option( 'skd_settings' );
?>
<input type='text' name='skd_settings[skd_text_field_3]' value='<?php echo $options['skd_text_field_3']; ?>'>
<?php
}
function skd_text_field_4_render( ) {
$options = get_option( 'skd_settings' );
?>
<input type='text' name='skd_settings[skd_text_field_4]' value='<?php echo $options['skd_text_field_4']; ?>'>
<?php
}
function skd_text_field_5_render( ) {
$options = get_option( 'skd_settings' );
?>
<input type='text' name='skd_settings[skd_text_field_5]' value='<?php echo $options['skd_text_field_5']; ?>'>
<?php
}
function skd_settings_section_callback( ) {
echo __( 'This section description', 'wordpress' );
}
function skd_options_page( ) {
?>
<form action='options.php' method='post'>
<h2>skilte-designer</h2>
<?php
settings_fields( 'pluginPage' );
do_settings_sections( 'pluginPage' );
submit_button();
?>
</form>
<?php
}
已创建菜单项,但我尝试在上面生成的设置字段均未显示在选项页面上。
我可以点击菜单项,但页面则为空。
我在这里做错了什么?
答案 0 :(得分:0)
我认为你错过了add_action的位置(&#39; admin_menu&#39;,&#39; skd_add_admin_menu&#39;,13);
答案 1 :(得分:0)
我错过了在add_action skd_options_page()
中调用选项功能