The question is from a long time ago but, just for reference, in this particular case and if somebody simply wants to use the checked
function with what seems to be an array
(instead of doing the test and output ‘checked` on the spot) here is a drop-in solution:
checked( in_array( $shopCategory->term_id, $term_meta['ss_aff_categories'] ) )
This works because checked
can take only one argument and compare the value of it with the default second argument which is set to boolean
true
. So in this case, if the $shopCategory->term_id
value is in the $term_meta['ss_aff_categories']
array the in_array
function will return boolean true
. Ultimately, the value that we pass to checked
, along with the default second argument of checked
, are converted to strings and compared.
Related Posts:
- Support auto-save and revisions for custom fields
- Best choice of options/settings framework for plugin/theme development
- Strange issue saving custom field data for a WooCommerce order
- How can I add an image upload field directly to a custom write panel?
- framework for plugin/theme options panel? [closed]
- How do I add CSS options to my plugin without using inline styles?
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Is get_option function cached?
- How come `wp_options` table does not have an index on `autoload`?
- Update Option Stored in Multi-Dimensional Array
- What are the advantages to the Settings API?
- Adding Widget form fields dynamically
- How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?
- Where to store plugin settings fields
- Is get_option() faster than accessing get_transient()?
- How to validate custom fields in custom post type?
- How to add tab which is visible only in admin side of product in woocommerce? [closed]
- What’s the best method for emptying an option created with the Settings API?
- Releasing new plugin version, how to rename old options keys?
- WordPress updates defined vs add_filter?
- Creating Settings Page with dropdowns for Plugin
- How to properly sanitize strings for update_option()
- Creating custom field with drop down on new post page
- How to add a new plugin page under desired Options page?
- A Post is saved twice or more during add_action(save_post)
- Save metabox with multiple checkbox array
- Retrieving custom fields with $wpdb->get_results
- How do I handle multiple Submit buttons in plugin’s option page?
- How to create Image gallery Metabox in wordpress [closed]
- Utilize TinyMCE hyperlink chooser outside of TinyMCE
- Deletion of shared options using uninstall.php
- anything like add_meta_box for categories?
- Why won’t register_setting() create a setting?
- Conflicting save_post functions when passing the post id and saving custom meta boxes for different post types
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- Dropdown list of pages to get page id to store in plugin options
- update_option is not working!
- update_option_{$option} Too Few Arguments
- Save user-specific options in WordPress admin
- How to store accumulate multiple option values in a single array using Options_API
- Creating option to allow user to select the page my plugin content will display on
- template_redirect for single posts w/ custom fields
- Unified Approach for Placing Option Pages
- array_map() for sanitizing $_POST
- WordPress plugin options and jQuery
- WordPress Plugin Setting’s POST
- Performance of several get_option() calls
- Extend plugin options page
- Can I use the different settings sections over different pages using the save options group?
- Options API – Validation Callback $input is NULL
- save_post hook not triggered in WP v3.6.1
- Correct way check nonce (security) using old Options API
- Ordering posts by metadata
- How to store a medium amount of options?
- How to add settings subpage from a plugin to a settings page created in theme?
- Plugin options not being saved or created
- Remove Internal Style Sheet if no Value Provided?
- What could cause my plugin’s options/settings page not to load?
- How to set “Site Address (URL)” programmatically on WP multisite?
- WordPress setting with select – where is my mistake?
- Using wp_parse_args to set up Plugin Default Settings
- using new WP_Query in save_post function alters $post
- Adding set of custom fields to WordPress Post in Dashboard
- get_posts() not working when accessing with a custom user role
- Custom delete option button in plugin settings
- Storing product price data in the database
- How To Change Post Author Default?
- Custom Taxonomy to dropdown box on adminside wordpress
- WP_Editor – Saving Value into Plugin Option – Stripping HTML
- Editing options pages?
- Create & Save multiple Meta-boxes
- Saving value of a selection option in comment form as comment meta
- Multiple options pages validation for a plugin
- Plugin with action ‘save_post’ needs to press publish twice on order to publish
- Woocommerce – Convert Delivery method into a custom field
- How to get Metabox custom field to show checked if value is updated using post meta query?
- How do I update a field of a meta box?
- get_option() not returning expected value from plugin
- Parse form values before sending to options.php
- Input value from metabox is not found in $_POST after post save
- Run Shortcode of post’s custom field in functions.php / Plugin
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Update problem with update_option() in combination with register_setting()
- Custom code for WordPress dynamic menu
- Insert/Update values to a table after blogname option etc. is updated
- Access bloginfo, get_option, and plugins_url from a non-core php file
- wordpress how to query wp_options table
- How Can I add Fields in wp-option table?
- Redirect to another page using contact form 7? [closed]
- Plugin Options Array Set to Undefined
- get_option() will not work without access to wp-config.php
- What is the best way to store a few fields?
- Delist entries in the_loop
- Bug: Post needs to be updated twice when adding action for save_post hook
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- How can I add a simple custom field to my plugin?
- Ajax is not working in a loop
- Issue on Checkbox with Custom Option Page
- Make Database query only when option is updated
- The Correct Way to Use Nonce Field without Settings API