register_setting & add_settings_error validation issues with multiple fields

If you want your sanitization callback to apply only to a specific settings field (i.e. a database option registered using register_setting()), then you would want to use a different callback for each of your settings fields. E.g. // Sample field HTML: //<input name=”field-1″ value=”<?php esc_attr( get_option( ‘field-1’ ) ); ?>”> function my_settings_field_1_validation( $value ) { … Read more

Add description to custom plugin setting

I’ve not seen this type of title settings layout in the admin pages, so it seems you’re parting away from it. Otherwise note that the title field of add_settings_field() is unescaped, so in theory one could add some HTML code for new title layout. Usually the description is added to the input field.

how to save checkbox data for custom setting?

Your checkbox data is saved as 1 or ” if someone checked or unchecked it. you can also verify this using var_dump($checkbox) inside custom_checkbox_field_html function This should work. function custom_checkbox_field_html(){ $checkbox = get_option( ‘disabletitle_text’ ); $is_checked = ( $checkbox != ” && $checkbox == 1 ) ? ‘checked’: ”; printf( ‘<input type=”checkbox” id=”disabletitle_text” name=”disabletitle_text” value=”1″ … Read more

Get categories names as an array to use it in theme settings

Thanks Michael for the tip. I finally got it. The solution is as follows: $options[] = array( “section” => “zzz”, “id” => HS_SHORTNAME . “_multicheckbox_inputs”, “title” => __( ‘Multi-Checkbox’, ‘hs_textdomain’ ), “desc” => __( ‘Some Description’, ‘hs_textdomain’ ), “type” => “multi-checkbox”, “std” => ”, “choices” => my_list_cats() ); And in functions.php: function my_list_cats() { $cats … Read more

Color Options from Theme Customizer API not returning via get_theme_mod()

If your settings are stored as Theme Mods, rather than as a Settings API option, then you need to pass the appropriate value to the type parameter to $wp_customize->add_setting(): ‘option’: Settings API option (get_option()) ‘theme_mod’: Theme Mods API option (get_theme_mod()) Try changing this: $wp_customize->add_setting( $this_theme . ‘_theme_options[‘. $setting .’]’, array( ‘default’ => $param[‘default’], ‘sanitize_callback’ => … Read more

Save and user submitted data from a form and display them in the wp backend

Can you just tell me how I can grab the input value for “name” and add the entry to custom_post_type? Sure thing: if ( isset( $_POST[‘name’] ) ) { $name = sanitize_text_field( wp_unslash( $_POST[‘name’] ) ); if ( $name ) { wp_insert_post( array( ‘post_title’ => $name, ‘post_type’ => ‘my_post_type’, ‘post_status’ => ‘publish’, /* Or “draft”, … Read more

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