Theme option page doesn't save options
I am trying to practice adding theme options page using settings API but unfortunately the code i have written according to the codex doesn't work properly. When i tested the code no errors generated but the pe_bannar_heading
option can't be saveed , So would you please help me find where the problem is in the following code
?php
/*
Plugin Name: Test option page
Text Domain: test-option-page
*/
function reg_settings(){
register_setting('pe_theme_options','pe_theme_options');
add_settings_section('pe_main_settings','Main Settings', '', __FILE__);
add_settings_field('pe_bannar_heading', 'Bannar Heading:', 'pe_bannar_heading_setting', __FILE__, 'pe_main_settings');
}
add_action('admin_init','reg_settings');
function pe_bannar_heading_setting(){
$options = get_option('pe_theme_options');?
input name="pe_bannar_heading" type="text" value="?php if(isset($options['pe_bannar_heading'])) echo $options['pe_bannar_heading'] ?"/
?php }
function pe_add_menu_page(){
add_options_page('Theme Options', 'Theme Options', 'administrator', __FILE__ , 'display_options_page');
}
add_action('admin_menu','pe_add_menu_page');
function display_options_page(){
$options = get_option('pe_theme_options');?
div class="wrap"
h2Yellow Blog Options/h2
form action="options.php" method="post" enctype="multipart/form-data"
?php
settings_fields('pe_theme_options');
do_settings_sections(__FILE__);
submit_button( 'Save Settings' );
?
/form
/div
?php }
Topic theme-options theme-development Wordpress
Category Web