Your code has
var getid = $('#my-categorychecklist input:checked').last().val();
see the .last(), that’s why you’re only getting the last item
Also, why do you have the same thing in getid and matchid?
You need to store the selected categories in an array and loop through them,
try something like:
var selected_cats = $('#my-categorychecklist input:checked').map(function() {
return this.value
})
(without the .get())
then loop through them with
selected_cats.forEach(function(element) {
console.log(element)
//make sure element has what you're expecting then do you something on element
}
Try doing console.log() on each variable and see in your console, if the the variables have the result you’re expecting. Make sure that selected_cats has an array of the selected categories
Related Posts:
- How to get Metabox custom field to show checked if value is updated using post meta query?
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
- How can I add an image upload field directly to a custom write panel?
- ajaxurl not defined on front end
- Why does WordPress add 0 (zero) to an Ajax response?
- How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?
- How to validate custom fields in custom post type?
- Saving data-URI to media library
- How to add tab which is visible only in admin side of product in woocommerce? [closed]
- Nonces can be reused multiple times? Bug / Security issue?
- How can I run AJAX on a button click event?
- How-to implement admin Ajax inside an admin WP_List_Table?
- What is nonce and how to use it with Ajax in WordPress? [duplicate]
- Empty POST data on server on AJAX request using Angular $http
- Creating custom field with drop down on new post page
- Using AJAX in FrontEnd with WordPress Plugin Boilerplate (wppb.io)
- Build path for a custom portfolio plugin
- Save metabox with multiple checkbox array
- Using AJAX in a plugin to submit form – REALLY confused
- wp_localize_script $handle
- How to Make a Category Always Selected?
- Retrieving custom fields with $wpdb->get_results
- How to create Image gallery Metabox in wordpress [closed]
- Utilize TinyMCE hyperlink chooser outside of TinyMCE
- How to enable users to down-vote in this simple voting counter (that uses the post meta)?
- anything like add_meta_box for categories?
- Adding callback function for wp_ajax_ has no effect
- get all products of one category
- Get returned variable from a function to add_shortcode function
- Plugin Settings not Saving on Ajax re-ordered table
- How to post form in ajax mode and handle it in wordpress
- Using Ajax call in jQuery doesn’t work in widget
- WP_LOCALIZE_SCRIPT doesn’t work
- template_redirect for single posts w/ custom fields
- Timeout on Admin-Ajax?
- Admin-ajax.php appending a status code to ajax response
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- Ajax in WordPress – path issue
- Cannot search post by taxonomy
- Support auto-save and revisions for custom fields
- Best choice of options/settings framework for plugin/theme development
- WordPress Ajax callback function from plugin – OOP
- Ordering posts by metadata
- WP AJAX is not working, always returns 0
- Ensure function has completed before allowing another Ajax call
- Get Objects While Deleting term
- Frontend Ajax call not working using wp_ajax, wp_enqueue_script and wp_localize_script
- Fetching the value of forms in WordPress AJAX
- include wp-blog-header not working on MAMP
- Adding set of custom fields to WordPress Post in Dashboard
- Any problem in using native jquery ajax style instead of using admin-ajax.php?
- Slow WP_query due to nested wp_query. Need Suggestions
- Show special field when correct shipping is chosen
- get_posts() not working when accessing with a custom user role
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Custom Taxonomy to dropdown box on adminside wordpress
- Woocommerce checkout update totals with datepicker
- Including the necessary functions for a custom ajax registration form
- Create & Save multiple Meta-boxes
- Saving value of a selection option in comment form as comment meta
- How can I rewrite a URL to pass requests to a custom method via AJAX? (I can’t use admin-ajax.php)
- How to localize admin.php only once
- get post attachment using ajax
- Dashboard – get status and position of metaboxes and pass them to ajax method
- Strange issue saving custom field data for a WooCommerce order
- Create a new post using rest api and save featured image using an external image url
- Woocommerce – Convert Delivery method into a custom field
- how to search users by ajax live search
- Notice: Trying to get property ‘term_id’ of non-object
- wp.template() returns tags in Ajax response
- How do I update a field of a meta box?
- Storing data in wordpress database from ajax call from different website
- Input value from metabox is not found in $_POST after post save
- Fatal error: Uncaught Error: Call to undefined function get_option()
- Run Shortcode of post’s custom field in functions.php / Plugin
- Create custom HTML/JS app inside page
- Use just a shortcode from another page
- template_redirect or admin-ajax.php?
- How to Get Current Custom Post Type Associated Taxonomy Term
- Custom code for WordPress dynamic menu
- How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?
- how to get context information inside my funcion
- wp_get_post_terms Order by not working
- AJAX form post returns 0
- Update Data parameter of a wp_localize_script() call
- Checked() function on a multidimensional array
- jquery & ajax sending data to php
- wp_localize_script is not adding a global variable for javascript
- What is the best way to store a few fields?
- Delist entries in the_loop
- Custom post type’s extra fields – how to handle?
- Can’t get AJAX call working in custom plugin
- Bad Request in AJAX
- 400 Bad Request, in wordpress theme development, wp_ajax
- How can I add a simple custom field to my plugin?
- ajax recursive calls on wordpress returning answers outsite the function scope
- Ajax submit result opens in admin-ajax.php