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 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?
- How to add tab which is visible only in admin side of product in woocommerce? [closed]
- How can I run AJAX on a button click event?
- What is nonce and how to use it with Ajax in WordPress? [duplicate]
- Empty POST data on server on AJAX request using Angular $http
- 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?
- Utilize TinyMCE hyperlink chooser outside of TinyMCE
- get all products of one category
- Get returned variable from a function to add_shortcode function
- 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
- Ajax in WordPress – path issue
- Cannot search post by taxonomy
- Best choice of options/settings framework for plugin/theme development
- WordPress Ajax callback function from plugin – OOP
- WP AJAX is not working, always returns 0
- Frontend Ajax call not working using wp_ajax, wp_enqueue_script and wp_localize_script
- Adding set of custom fields to WordPress Post in Dashboard
- Slow WP_query due to nested wp_query. Need Suggestions
- Woocommerce checkout update totals with datepicker
- Including the necessary functions for a custom ajax registration form
- How can I rewrite a URL to pass requests to a custom method via AJAX? (I can’t use admin-ajax.php)
- Dashboard – get status and position of metaboxes and pass them to ajax method
- Strange issue saving custom field data for a WooCommerce order
- Woocommerce – Convert Delivery method into a custom field
- Notice: Trying to get property ‘term_id’ of non-object
- 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
- Create custom HTML/JS app inside page
- How to Get Current Custom Post Type Associated Taxonomy Term
- Custom code for WordPress dynamic menu
- wp_localize_script is not adding a global variable for javascript
- Delist entries in the_loop
- Can’t get AJAX call working in custom plugin
- 400 Bad Request, in wordpress theme development, wp_ajax
- How can I add a simple custom field to my plugin?
- Are there any security risks when submitting data-attribute data through AJAX?
- term_exists() returning NULL on term that exists
- How to get error object returned by wp_create_user
- Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
- Data not insert and update through ajax and jQuery in admin page?
- WP ajax requests not stacking?
- AJAX button with success callback. (Titan Framework)
- ajax working when function is on child theme but not in plugin page
- How to format custom fields when editing an attachment?
- How add default term meta to prevent an error?
- AJAX call returns ‘testtest0’ instead of ‘test’ – why?
- About a programming language starts with [closed]
- add_action wp_ajax_ not loading in plugin file WP Network
- Workflow for new importer plugin – your advices?
- Ajax +wordpress onClick link redirect to new page and create html content
- Any way to update_post_meta with html content? It gets stripped and becomes empty
- Customise Grouped Product display in Woocommerce with custom column
- WordPress (pagenow link) in ajaxurl change after i change plugin language
- How to do admin ajax request in a plugin for rest api
- Ajax action has 200 status but response of No response data available for this request
- Jquery php request is returning a weird result
- WordPress Does not grab the string sends useing AJAX response, wp_ajax hook
- Posts form with AJAX request – Plugin development
- Bad request 400 using class based files
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- WP_Query not ordering correctly
- Adding customs fields on each product on the cart
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- Rate limiting ajax requests in WordPress
- ajax-action.php can’t find added action
- AJAX call of function containing javascript which is not loaded (Plugin development)
- Performing ajax request in wordpress
- ajax multiple Values
- How to include files in the loop via ajax
- How to handle ajax Request in a complex-structured plugin?
- Using JavaScript in WordPress page to call for server data using AJAX
- wp_ajax add_action fuction won’t fire on custom jQuery action
- Filterable posts using categories
- Ajax Response Error | just getting error as the response
- PHP includes with AJAX actions
- admin-ajax.php returns “No Script Kiddies!” sometimes
- WordPress function is not called and ajax return 0
- Displaying Custom Post Meta
- Ajax functionality not being called under wordpress plugin
- Array/List Edit in Backend
- WP Cron as Fast as WordPress AJAX?
- WordPress plugin: admin-ajax.php not passing data to custom function
- How to display custom taxonomy and terms using/creating plugin template
- Ajax functions – no access to wp-admin.php only online
- Page reload occurs before request finishes
- I want to display the content of a text field only if it has been entered
- Create Unique and Customized User ID for Website Members in WordPress
- PHPUnit Ajax Serialization of ‘Closure’ is not allowed
- Return custom product in ajax call loop