I can’t get my options page to show any of the added input fields.
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
}
The menu item is created, but none of the settings fields that I try to generate above is showing up on the options page.
I can click on the menu item but the page is then empty.
What am I doing wrong here ?
I think you missed position here in add_action( ‘admin_menu’, ‘skd_add_admin_menu’ ,13);
I missed to call the option function in add_action skd_options_page()