Just set the name
attribute in your checkbox tag in the format like: favourite_colors[]
. The following code is derived from this thread.
add_settings_field(
'favourite-colors',
'Select your favourite colour',
'favourite_colors_checkbox_callback',
'my-settings'
);
function favourite_colors_checkbox_callback() {
$options = get_option( 'favourite_colors' );
$html="<input type="checkbox" id="red" name="favourite_colors[red]" value="1"" . checked( 1, $options['red'], false ) . '/>';
$html .= '<label for="red">Red</label><br />';
$html="<input type="checkbox" id="yellow" name="favourite_colors[yellow]" value="1"" . checked( 1, $options['yellow'], false ) . '/>';
$html .= '<label for="yellow">Yellow</label>';
echo $html;
}
Related Posts:
- How to get the Date Format and Time Format settings for use in my template?
- Custom editor field displaying HTML in Visual editor
- On Install, which code sets the ‘home’ option?
- How to use get_option() without any filter?
- Custom widget select options needs to stay selected after save
- Include user defined styles without including wp-load
- Warning: Creating default object… when altering Customize panels
- WordPress slugs and 404 handling takes preference over folders in site root?
- What changes we need to make to a theme so it can be installed as a MU Theme?
- How do I make mysite.com/comingsoon WordPress to become my main website’s WordPress?
- How to add the option to choose between sizes for featured image within post editor?
- Edit a custom admin page
- Custom options – register, defaults and delete empty fields (Settings API)
- How to delete orphan userdata from array in wp-options
- retrieve theme custom settings
- Is there a flowchart for WordPress loading sequence?
- Custom maintenance page
- How to customize the default HTML for WordPress Attachments
- Customizing the Subject Field in WordPress’ Notification Emails?
- Is it possible to change the attributes of a registered style or script before it fires?
- how to change “published date” format on edit.php (Posts page)?
- How can I integrate pages written in something other than PHP?
- How to change submit button value in comment from “Post Comment” to “Send”
- How to update widget from widget() function?
- Custom field values in permalink
- Creating a searchable A-Z listing of hundreds of companies/services
- Custom protected password page with ACF
- Customize in category page
- Custom Dashboard Home Screen Options
- How to get WordPress to accept the tag in articles (or other alternatives)
- Add custom column to Users admin panel with Types user custom fields?
- How do I change the default admin color scheme in MP6
- dynamic external javascript generated using php
- What’s the proper way to use a custom table? [closed]
- woocommerce Add custom field set like billing fields
- How can a single line in a blog post take down my server?
- Calling a php file from a javascript file in wordpress
- Adding a Table to the wordpress database
- Integrate WordPress into existing website
- How can I use get_bloginfo(‘admin_email’) in a custom PHP file?
- how can I change the background color of all posts on my server?
- Auto redirect after session expire, but only for one user
- Turn off redirect to canonical domain (or host website on any hostname)
- CSS to remove “comments count” icon from main page [closed]
- What’s wrong with Customizing new user notification email by add_filter?
- Custom title, Bones theme
- How to change the category url jusy show /category/%category_id% in wordpress?
- How can I display a PHP foreach loop’s answers by AJAX
- No shipping method has been selected [closed]
- Child Theme with multiple css files
- Organizing the position of widgetized areas in the backend
- How do I redirect a post url to a custom url?
- How to customize
- Why the css in twenteenfourteen-child theme take no effect?
- Determine if action was executed in functions
- Saving contact form 7 data into custom Table
- add custom content to appearance/widgets screen
- css media query question [closed]
- How to create a page /1 using ?
- Open “Visit site” in a new window?
- Hiding Short Description in Shop Page, WooCommerce
- theme customizer – can a single option pass multiple values?
- Separate header for static home page and posts page
- Media Upload not working after hiding some elements from functions.php
- Pagination with custom field
- What’s the right way to share data between widgets?
- Importing specified data/field
- Customizing the gallery of the post correctly
- How to retain visual breadcrumbs w/ tricky URL structure? Custom post template?
- Mimicking admin panel menu from wordpress 3.0.1
- query variables for custom taxonomies
- Will WordPress updates remove Gutenberg Additional Classes?
- WP_Query – sort the results by meta value custom attribute wocoomerce
- Adding overlay search to wordpress using add action/filter
- wordpress custom fields loop
- Multiple header style under meta box
- why won’t my custom css load with the enqueue method or any other method?
- How do I add a dropdown menu to a form?
- How can I create a Custom Page? (not a page template!!)
- save short-code in my custom plugin settings problem missed something
- Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
- How to have different background image based on post category
- POST 429 Error when trying to place more than 20 images into post at once
- How to add rewrite rule for product compare page?
- Custom stylesheet not loading
- Custom Admin Section
- Local and live synchronized dev and production environment [closed]
- issue with saving custom metaboxes fields
- Getting a jQuery library to work in WordPress & Avada
- DOM reference to TinyMCE editor element (button)
- Allow arbitrary text after page URL
- Possible to make a site like urban dictionary using WP?
- Turn Autocomplete on
- Change the functionality of wordpress users module in admin
- Custom Post want button to add image and save in Postmeta
- Save And Display Mp3 Audio files on WooCommerce product page with Dokan
- Advice how to connect custom database with WordPress, change data in WordPress and finaly use this data
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- Is it possible assign a secondary existing role to already existing one?
- Set custom banner image size with wp_customize