I had the same problem, and here what works for me:
function journal_check_cats_callback() {
$options = get_option('journal_theme_blog_2_col');
$pag = journal_theme_blog_2_col;
$_cats = get_terms( 'category' );
$html="";
foreach ($_cats as $term) {
$checked = in_array($term->term_id, $options) ? 'checked="checked"' : '';
$html .= sprintf( '<input type="checkbox" id="%1$s[%2$s]" name="%1$s[]" value="%2$s" %3$s />', $pag, $term->term_id, $checked );
$html .= sprintf( '<label for="%1$s[%3$s]"> %2$s</label><br>', $pag, $term->name, $term->term_id );
}
$html .= sprintf( '<span class="description"> %s</label>', '' );
echo $html;
}
Related Posts:
- How to pass arguments from add_settings_field() to the callback function?
- esc_url not working within add_settings_field callback
- How can one utilize a variable as a callback function name for add_settings_field
- How to validate register settings array
- settings_fields doesn’t appear to be running
- Stop post being published
- Settings API callback function inserts html quotes from nowhere
- call_user_func_array expects parameter 1 to be a valid callback
- Code works, but warning about call_user_func_array() appears
- custom-background callback breaks media uploader
- Category callback box problem
- Custom Post Type Settings page, choose page to display archive
- Where to store plugin settings fields
- wp_editor() fields on Theme Options Page not saving
- What’s the best method for emptying an option created with the Settings API?
- Image upload callback in new 3.5 media
- Settings API – easiest way of validating checkboxes?
- Adding an html editor to plugin settings page
- WP showing “warning: call_user_func_array()”, What to do?
- Where to store some per-template preferences?
- Hooking a callback into the code within a Gutenberg block
- Add_settings_field() parameterizing callback?
- Validate an option array
- How can I include a setting that has a variable number of values in a settings page using register_setting?
- Serialized settings in rest api
- Disable $title in Plugin Options Screen?
- Get returned variable from a function to add_shortcode function
- WordPress Settings API: saving multiple rows of similar data
- How to Override default update_count_callback for category
- Reference external file as a function
- Settings API – how to update options manually?
- Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?
- Add custom content in user-edit.php page
- Plugin set default setting value when it activated
- wp_insert_post() Callback?
- Can I dynamically create duplicate fields with the Settings API?
- Stop the form of beign submitted on “Save changes” custom option page
- Settings API – input always updates over validation
- When should I call add_settings_section and add_settings_field?
- What exactly is the purpose of settings_fields()?
- Can I use the different settings sections over different pages using the save options group?
- How to add a secondary button to a settings page with a custom action?
- Settings API: Change position of custom setting field
- Settings not set after calling register_setting()
- Hide output of add_settings_field()
- Storage of array in settings
- Settings API and dynamically generated submenu pages
- Gutenberg: How to check if a block is used in a paginated post?
- Error: options page not found when I try to save the changes made in my settings page
- Problems with comments callback (Argument #1 is not an array?)
- WordPress Settings API – Sanitize Integer
- Settings API – Separating PHP and HTML
- Why are these settings unregistered?
- Plugin development: can’t update settings with multiple settings sections
- Most efficient way to use classes to create admin pages using Settings API
- Shortcode function executed twice?
- How to access $post from a callback function
- Getting error to display radio button value in General Settings page
- Get URL Parameters from referer
- Filter an array with a callback – for single & multidimensional arrays
- How to return multiple arguments from AJAX callback function
- Settings API settings section not appearing
- hide wp-content from urls
- Allow HTML in Settings API input field
- settings api sub menu and data not populating
- register_settings callback function erases data
- Warning: call_user_func() expects parameter 1 to be a valid callback, function
- custom wp_editor does not save the content in plugin settings
- Retrieve post in AJAX Callback
- ‘delete_option()’ only deleting the value, not the key/value pair
- add_settings_field (exclude categories->reading) wp_category_checklist
- How to use checked() function with multiple check box group? How to properly sanitize that checkbox group?
- Tabbed theme options query about add_settings_section callback function
- Pause plugin option page until all data manipulation is complete
- How to make sure settings are not lost when plugin is updated?
- Add a field in my rest api
- 403 Error When Fetching Data from the Settings Rest Route for Non-Admin Users
- Custom plugin: how do I call a PHP file if settings option is set to true?
- Sanitization and validation input fields – Settings API
- Is there a standard technique or API for getting the site header image?
- WordPress Settings API Overrides My Previous Value
- How to save Checkbox-Options in Plugin Options Page
- register_setting not save checkbox
- Multiple plugins linked to same settings page
- Plugin setting page – update_option problem
- How Can I Update wp_enqueue_scripts () From WordPress Option Page Radio Buttons
- Customizer settings using “for” loop
- Add two input fields in add_settings_field
- Warning: call_user_func() expects parameter 1 to be a valid callback
- Unregister Settings Error
- Generate activation url
- call user func array error after moved the site to new server
- Validating values using Settings API?
- Settings api sanatize callback not being triggered
- Reference external file as a function
- Options don’t save, validation callback not executed
- Creating your own options-general.php page
- illegal offset in option add
- Update custom settings field in plugin
- Settings API not Saving to Database or Display