Why are these settings unregistered?

The error message is actually misleading here. WP isn’t checking if the settings are registered — e.g., if ( isset( $GLOBALS[‘wp_registered_settings’][‘foo’] ) ) — it’s checking if the form was posted to the default options page (options.php), rather than a custom one (options-general.php?page=foo). So, it’s entirely possible to get this warning after calling register_setting(), if … Read more

Splitting do_settings_sections within HTML?

Nevermind, figured it out. Made the following changes: add_settings_section( ‘cp_required_info’, null, array($this, ‘cp_required_info’), ‘cp-settings-group’ ); add_settings_section( ‘cp_sync_info’, null, array($this, ‘cp_sync_info’), ‘cp-settings-group’ ); register_setting( ‘cp-settings-group’, ‘cp_admin_options’, array( $this, ‘sanitize’ ) ); <?php settings_fields( ‘cp-settings-group’ ); do_settings_sections( ‘cp-settings-group’ ); do_settings_fields( ‘cp-settings’, ‘cp_required_info’ );?> <!–Some HTML goes here–> <?php do_settings_fields( ‘cp-settings’, ‘cp_sync_info’ );?> ?>

add_settings_section() order

You can adjust the priority of dr_issue_settings_init() so that it fires after the default of 10. This should make it appear after the existing settings on the same settings page. function dr_issue_settings_init() { add_settings_section( ‘dr_issue_section’, //$id __( ‘Issue settings’ ), //title ‘dr_issue_section_callback’, //callback ‘mytheme_settings’ // page ); } add_action( ‘admin_init’, ‘dr_issue_settings_init’, 100 );

Preserve old values on error in setting API

Unfortunately WordPress does not provide the old value as an additional argument to your sanitize_callback callable. This is supported in general by the option validator hook that WordPress calls when saving the updated setting… return apply_filters( “sanitize_option_{$option}”, $value, $option, $original_value ); …but in practice it is not actually registered with any additional arguments when the … Read more

Display Each Setting Section In Each Specific Tab within Same Page || Settings API

Incase anyone stumbles across this, I recently encountered the same issue and was able to render the differnet using do_setting_fields( $page, $section ) instead of do_settings_sections( $page ). As per the settings api, do_settings_sections prints out all settings sections added to a particular settings page, whilst do_settings_fields prints out the settings fields for a particular … Read more

Error: options page not found when I try to save the changes made in my settings page

The problem is in my file settings.php (which renders the form). Look at the form action. It says action=”options.php” and then the settings_field() inserts a hidden field with the correct action. But WordPress prioritizes the form action, so, when submit the form, WordPress tries to load options.php instead of the correct action in the hidden … Read more

Settings API and dynamically generated submenu pages

I think the approach you’re attempting is prohibitively complex, and will not scale well at all. I would suggest two possible alternatives to the approach you’re trying to take: Create a Widget to display your Plugin output, so that the Widgets API handles the settings for multiple instances of your Plugin output. Create a Shortcode … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)