Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I added a section for my options, everything works fine. I added a new section (social) and after that I can't save the content of the "General Options" form. The business section is working. Where is the bug?

add_action( 'admin_menu', 'theme_add_page' );
function theme_add_page() {
    $theme_options_page = add_menu_page( 'Theme Options', 'Theme Options', 'manage_options', 'theme-options', 'theme_options_page' );
    add_action( 'admin_print_scripts-' . $theme_options_page, 'themeoptions_print_scripts' );
}

function theme_options_page() {
    ?>
    <div class="wrap">
        <div id="icon-tools" class="icon32"></br></div>
        <h2>Theme Options</h2>
        <?php if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] ) : ?>
            <div class="updated"><p><strong><?php _e('Settings saved.', 'magaziner'); ?></strong></p></div>
        <?php endif; ?>
        <form action="options.php" method="post">
            <?php settings_fields( 'general_options' ); ?>
            <?php do_settings_sections( 'general_options' ); ?>
            <?php settings_fields( 'business_options' ); ?>
            <?php do_settings_sections( 'business_options' ); ?>
            <?php submit_button(); ?>
        </form>
    </div>
    <?php
}

add_action( 'admin_init', 'theme_add_options' );
function theme_add_options() {
    register_setting( 'general_options', 'general_options', 'google_font_fix');
    register_setting( 'business_options', 'business_options');

    add_settings_section( 'general_section', __('Settings', 'magaziner'), 'general_section_callback', 'general_options' );
    add_settings_section( 'business_section', __('Business Settings', 'magaziner'), 'business_section_callback', 'business_options' );

    function general_section_callback() {}

    add_settings_field( 'mainbg', __('Main background', 'magaziner'), 'mainbg_callback', 'general_options', 'general_section' );
    add_settings_field( 'fonts', __('Google Fonts', 'magaziner'), 'fonts_callback', 'general_options', 'general_section' );
    add_settings_field( 'analytics', 'Google Analytics', 'analytics_callback', 'general_options', 'general_section' );
    add_settings_field( 'facebook', __('Facebook profile', 'magaziner'), 'facebook_callback', 'general_options', 'general_section' );
    add_settings_field( 'twitter', __('Twitter profile', 'magaziner'), 'twitter_callback', 'general_options', 'general_section' );
    add_settings_field( 'googleplus', __('Google+ profile', 'magaziner'), 'googleplus_callback', 'general_options', 'general_section' );
    add_settings_field( 'youtube', __('Youtube profile', 'magaziner'), 'youtube_callback', 'general_options', 'general_section' );
    add_settings_field( 'Address', __('Address', 'magaziner'), 'address_callback', 'business_options', 'business_section' );
}
share|improve this question
The problem is with the form, if I remove the business related lines the save is working but I need both.. :/ – robert Mar 21 at 1:15
Can you show me the whole theme options code including themeoptions_print_scripts function... – Vinod Dalvi Mar 21 at 4:25
You can't have multiple settings_fields() inside one <form>. Explore the HTML source of your options page (particularly <form> itself) and you'll see two sets of <input>-s with different data there. – Max Yudin Mar 21 at 9:09

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.