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?
- 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`?
- What are the advantages to the Settings API?
- Adding Widget form fields dynamically
- Is get_option() faster than accessing get_transient()?
- 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)
- 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]
- Deletion of shared options using uninstall.php
- anything like add_meta_box for categories?
- Why won’t register_setting() create a setting?
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- update_option is not working!
- Save user-specific options in WordPress admin
- How to store accumulate multiple option values in a single array using Options_API
- template_redirect for single posts w/ custom fields
- array_map() for sanitizing $_POST
- WordPress Plugin Setting’s POST
- Performance of several get_option() calls
- Extend plugin options page
- 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
- get_posts() not working when accessing with a custom user role
- 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?
- get_option() not returning expected value from plugin
- Parse form values before sending to options.php
- Run Shortcode of post’s custom field in functions.php / Plugin
- Update problem with update_option() in combination with register_setting()
- Insert/Update values to a table after blogname option etc. is updated
- 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
- WordPress publish_post hook not getting featured image and meta on first publish, but works on updating title
- Settings API: Setting default option via ‘get_option’ fails
- How to save post meta as an array in Gutenberg?
- Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
- per blog metadata for plugin
- how to save wp_editor html content in options table
- Problem with display data from get_option
- How to format custom fields when editing an attachment?
- Use options to control jQuery plugin
- What could cause a WP Option to get truncated?
- Decontruct serialized data array from wp_options
- how to add custom fields into new & update post page?
- Customise Grouped Product display in Woocommerce with custom column
- How does one update complex options?
- Adding customs fields on each product on the cart
- Plugins Settings page not updating
- add_meta_box does not display meta box in Admin
- Run query on specific admin options page and send results to select field in another function
- add_settings_error on validating plugin options API
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- Cannot save settings value
- save_post not called in plugin / custom field still saving overwriting metaboxes
- the correct way to use options from settings page [closed]
- Add_menu_page and saving settings
- How can i call from custom fields to the category editor?
- Menu_slug used for creating options page
- Admin Message after Plugin Option Updated
- Can I log the searches that are returning 404 in the DB?