Set $options reference
Set $options reference
Set $options reference
Multi-select field for Taxonomy can’t save the value
Okay, I found the solution incase anyone else is need to do the same thing. function music_link_setting (){ $options = get_option(‘kw_theme_options’); wp_dropdown_pages( array( ‘name’ => ‘kw_theme_options[music_link]’, ‘echo’ => 1, ‘show_option_none’ => __( ‘— Select —’ ), ‘option_none_value’ => ‘0’, ‘selected’ => $options[‘music_link’] ) ); }
Remember you need the get_option parameter in quotes, like this: $option = get_option(‘paradiso_category_fields_option’); and to get the img url out of that database option you presented it would be: echo $cat_image[7][‘image’];
There are some functions associated with manipulating the variables found in the wp_options table. add_option(): Create a new value in the table. Example add_option(‘var_name’, ‘value’) will store option_name=”var_name” and option_value=”value”. add_option() is used only when saving a value for the first time. Has an autoload parameter. get_option(): Retrieve that value. Example: get_option(‘var_name’) will return the … Read more
How to store options in an array
Here is the answer to my question… Add this to your functions.php // Options Page Functions function themeoptions_admin_menu() { // here’s where we add our theme options page link to the dashboard sidebar add_theme_page(“Theme Color”, “Theme Color”, ‘edit_themes’, basename(__FILE__), ‘themeoptions_page’); } function themeoptions_page() { // here’s the main function that will generate our options page … Read more
The action attribute in the form tag redirects you to the options page. But you also need a hidden field with the plugin slug. Normally its a hidden field that looks like this <input type=”hidden” value=”/wp-admin/options.php?page=[plugin-slug]” name=”_wp_http_referer”> where [plugin-slug] is replaced by your plugin slug.
The get_option function has a second parameter that allows you to specify a default value as noted in the documentation here if I am understanding you correctly. Does this do anything? <input name=”show_introduction” type=”checkbox” id=”show_introduction” value=”true” <?php checked(‘true’, get_option(‘show_introduction’, ‘true’)); ?> />
The default category is stored in the options table under option named default_category , so you can do something like this: add_action(‘admin_init’,’set_user_default_cat_wpa89057′); function set_user_default_cat_wpa89057(){ global $current_user; if ( isset($current_user) ) { update_option( ‘default_category’, $current_user->user_login); } }