WordPress theme settings not saving

$options = get_option( ‘textdomain_settings’ ); ?> <input type=”checkbox” name=”textdomain_settings[textdomain_checkbox_field_0]” <?php checked( $options[‘textdomain_checkbox_field_0’], 1 ); ?> value=”1″> <?php Use this settings under Callback Field Function or you can generate code form here for settings api directly.

WordPress theme options checkbox default checked state

With the code that you’ve added to your question, you’re adding the HTML ‘checked’ attribute twice, which is probably why things are getting confused. You have it hard-coded as checked=”checked”, but then checked( 1, get_option( ‘theme_custom_option’ ), false ) will write another checked attribute corresponding to the actual value of the option. You should be … Read more

Is there a standard technique or API for getting the site header image?

All the out-of-the-box API endpoints are documented quite well here: https://developer.wordpress.org/rest-api/reference/ A quick look in the relevant places didn’t turn up a way to get theme elements (although I might have missed it). It’s trivially easy to setup new API endpoints; here’s a quick example you could pop into your funcitons.php to ‘hard-wire’ into that … Read more

Multiple checkbox doesn’t work in wordpress settings api

Here is the function I used to solve the problem function username_editor_roles_callback() { global $wp_roles; $roles = $wp_roles->roles; foreach ($roles as $role) { $roleName = $role[‘name’]; $output = sprintf(‘<input type=”checkbox” id=”ue_roles_checkbox” name=”username_editor_settings[ue_roles_confirm][]” value=”%1$s” %2$s><label for=”ue_roles_checkbox”>%1$s</label><br>’, $roleName, checked( in_array($roleName, (array) ue_settings_option()[“ue_roles_confirm”]), 1, false ) ); echo $output; } }

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