Which WordPress option stores the current active theme?

All those options are actually pointing to the active theme, but the difference is the value stored in each option: The options template and stylesheet both store the name of the active theme folder, e.g. twentytwentyone for the Twenty Twenty-One theme. But if you’re using a child theme, then stylesheet would be the name of … Read more

How to change the file upload directory on version 3.5?

In addition to what Joseph suggested, you can also define the upload path in the wp-config.php file like this: define( ‘UPLOADS’, ‘wp-content/’.’files’ ); If you’d like it outside the wp-content folder, specify path like this: define( ‘UPLOADS’, ”.’uploads’ ); For uploading to a folder like example.com/images, use this code: //Custom upload path define( ‘UPLOADS’, ”.’images’ … Read more

Settings API – how to update options manually?

That’s because your options are stored as a serialised array, in one row with name XX_theme_settings. To update one option, you would still need to retrieve the existing settings, ammend the appropriate value and update all options in your array together. For example: $my_options= get_option(‘XX_theme_settings’);//retrieve all options $my_options[‘XX_Option2’] = ‘my new value’; //amend value in … Read more

Proper use of option_page_capability_{$page_name}

So in this hook is not exactly looking for the {$page_name}. Once I replaced the {$page_name} part of this filter to the {$option_group} parameter from my register_settings() function, all is well in the land of WordPress. Here is what my update needed to look like. function bf_ins_capability(){ return ‘edit_posts’; } add_filter( ‘option_page_capability_bf_insurance_settings’, ‘bf_ins_capability’);

Single callback with multiple setting fields

add_settings_field() accepts six arguments, the last one is an array of arguments: add_settings_field($id, $title, $callback, $page, $section, $args); You can add custom values here, so you can reuse one callback. A simple example: add_settings_field( ‘foo’, ‘Foo’, ‘wpse_settingsfield_callback’, ‘my_page’, ‘my_section’, array ( ‘context’ => ‘foo’ ) // custom arguments ); add_settings_field( ‘bar’, ‘Bar’, ‘wpse_settingsfield_callback’, ‘my_page’, ‘my_section’, … Read more

Settings API – how to update multiple options manually?

Fetch current options, and be sure to return an array if empty: $current_options = get_option( ‘option_name’, array() ); Ensure desired options are in an array: $desired_options = array( /* whatever you need goes here */ ); Merge them, using [wp_parse_args()]1: $merged_options = wp_parse_args( $current_options, $desired_options ); Update update_option( ‘option_name’, $merged_options ); Of course, the trick … Read more

checkbox with get_option not working

Full code to add settings page with checkbox option. You don’t need loops and something else. WordPress will make everything for you. Get more info in Codex function wpse_319648_render_popup() { $options = get_option(‘wpse_319648_checkbox’); $default = isset($options[‘popup’]) ? $options[‘popup’] : 0; printf( ‘<input type=”checkbox” name=”%1$s[popup]” value=”1″ %2$s>’, ‘wpse_319648_checkbox’, checked($default, 1, false) ); } function wpse_319648_settings_page() { … Read more

Editor role not saving settings page for custom post type

In the wp-admin/options.php file you find filter with name created from your settings group to control permissions: $capability = apply_filters( “option_page_capability_{$option_page}”, $capability ); to fix issue, add filter with your desired permission level like: add_filter( ‘option_page_capability_programme_content’, ‘my_settings_permissions’, 10, 1 ); function my_settings_permissions( $capability ) { return ‘edit_pages’; }

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