I am using the WordPress Settings API to build an options page for my theme. I can't get the input elements to display in the admin. I think I've narrowed the problem to the do_settings_sections();
function as it is the only thing not rendering anything on the front end.
function cbc_theme_init() {
register_setting( 'cbcsettings-group', 'carousel_options' );
add_settings_section(
'cbc_carousel_section',
'Carousel Settings',
'cbc_carousel_section_callback',
'cbcsettings'
);
add_settings_field(
'cbc_slide_one_title',
'Title',
'cbc_slide_title_callback',
'cbcsettings',
'cbc_carousel_section'
);
} // end cbc_theme_init
function cbc_carousel_section_callback() {
} // end cbc_carousel_section_callback
function cbc_slide_title_callback() {
$options = get_option( 'carousel_options' );
/*if( !isset( $options[ 'slide_one_title' ] ) ) {
$options[ 'slide_one_title' ] = '';
}*/
$html = '<input type="text" id="cbc_slide_one_title" name="carousel_options[slide_one_title]" value="' . $options[ 'slide_one_title' ] . '" />';
$html .= '<lable for="cbc_slide_one_title">Title for first slide.</label>';
echo $html;
} // end cbc_slide_title_callback
function cbc_add_theme_page() {
add_theme_page(
__( 'Theme Options', 'cbcsettings' ),
__( 'Theme Options', 'cbcsettings' ),
'edit_theme_options',
'cbcsettings',
'cbc_theme_options_page'
);
} // end cbc_add_theme_page
add_action( 'admin_menu', 'cbc_add_theme_page' );
function cbc_theme_options_page() {
?>
<div class="wrap">
<h2>Theme Options - <?php echo wp_get_theme(); ?></h2>
<?php get_settings_errors(); ?>
<form method="post" action="options.php">
<?php
settings_fields( 'cbcsettings-group' );
do_settings_sections( 'cbcsettings' );
submit_button();
?>
</form>
</div>
<?php
} // end cbc_theme_options_page