Just check if $_POST contains key with id of correstponding term.
if (isset($_POST['recvid'][$term->term_id])) {
However, I would not loop through all the terms. get_terms
function has corresponding option. So, to receive all posted ids, you would do this (also note, that first parameter may be a string, no need for an array):
$brands = get_terms('recipebrands', [
'include' => array_filter(array_keys($_POST['recvid']), function($value) { return is_numeric($value); }),
]);
What above code does?
array_keys
returns $_POST array keys obviously.array_filter
filters out only numeric keys (see anonymous function).include
option ofget_brands()
allows you to specify exact ids of terms you require.
Related Posts:
- Comparing arrays within a loop
- Jquery ajax to custom php file: returning blank data
- PHP calling AJAX function that relies on passed PHP function values not working
- Looking for a better way to handle an ajax script that pulls in post data on click
- Data fetch and delete by ajax request
- How to add default images into theme customizer image control?
- Can’t use get_results() in ajax query
- Debugging PHP object during Ajax call in WordPress
- WordPress Ajax Data problem
- Display notification only once
- admin-ajax.php returning error 400 namespaced callback
- Access/update database with jQuery
- Passing jQuery value using Ajax to a page template
- ajax_object is not defined when ajax calls the function
- Page Reloads Before AJAX Request Finishes
- Why is this Ajax not working?
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Ajax return code 400
- Any possible way to make $wpdb->get_results() return anything else than array?
- How to make drop down post title
- wordpress count link clicks by ip address
- ajax, right way to do it and make it works?
- WordPress ajax doesn’t display object method on jQuery .change() function
- Problem with custom plugin using AJAX to pull info from php file
- Ajax random number always the same
- Call a PHP Function with Multiple Parameters that is outside the AJAX Handler
- Repeating admin-ajax.php not found error in admin
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- WordPress, AJAX and pre_get_posts using conditional tags
- How to send Ajax request from my plugin in admin dashboard?
- Refresh table data with Ajax
- get_children displaying images removed from the page
- AJAX success response is not working but it’s saving my changes
- WordPress Ajax Call inserting data but success response false
- Loading php file with AJAX in WordPress frontend
- AJAX – Returning Two JSON Objects with One PHP Function
- Get the URL of the page from which an ajax request has been launched within ajax callback
- unable to use ‘new WP_Query’ in AJAX call
- admin-ajax Firing Error 400 When Logged In
- Unset session variable on page reload / setup but exclude AJAX
- Add Ajax Hooks and Call from Custom Template PHP
- Making an AJAX call to refresh a table
- WordPress Ajax Always returning 0
- Using data sent via AJAX in multiple functions on a WP plugin
- Woocommerce with Lazy Load php and ajax
- Short code template + ajax
- Can I make get_users() query global?
- How to use AJAX to call php page with parameter
- My jQuery Ajax form submit is still refreshing page?
- javascript variable to wordpress php variable
- Output votes to div dynamically in wordpress
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Incrementing PHP variable onclick to display posts by month
- How to use AJAX in WordPress in MYSQL query?
- calling admin-ajax.php from admin-ajax.php
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- WordPress Custom Add To Cart Button with AJAX
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Display WordPress search results based on the selected Sub-Category
- jquery & ajax getting data from php in wordpress . admin-ajax.php returns 400
- Settings API form – submit with AJAX
- Load more posts using AJAX based on posts inside WP_Query
- PHP calling AJAX function that relies on passed PHP function values not working
- Where to add my PHP codes for AJAX Jquery to work?
- How to use wp_ajax_set_post_thumbnail?
- register_block_type is not working properly
- Submit remote form to wordpress REST API and save data to custom post type
- WooCommerce REST API AJAX Auth – 401 response
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- AJAX numerical pagination problem in TwentyFifteen-child theme
- How to reload a php script, using AJAX and jQuery
- Filtering custom posts by using checkboxes for taxonomy in an ajax loop always gives server 500 error
- Why my Ajax events are no longer detected after dynamic change of shortcode content
- Contactform7: display results from CURL
- Top Authors list by highest post views with Ajax pagination
- Offset with ajax load more posts duplicates
- ajax polling with admin-ajax.php
- Woocommerce variable products are being added to the card on the homepage (ajax)
- A javascript function that simply runs a php function on the plugin
- Ajax not updating to database
- WordPress 404 when using AJAX to call php function
- how use php query in AJAX jquery
- Ajax Load more CPT via shortcode
- Submitting my form to the database and then redirecting to payment site
- MySQL query in WordPress with AJAX
- wp_delete_comment is doing nothing
- Pass the updated value of aid from form using ajax
- Is custom behaviour possible when asynchronously uploading?
- Execute PHP code in Javascript onclick
- best way to communicate between php and jquery/javascript
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- Data inserted in database, but ajax calls error function
- AJAX: WordPress filters inside $html do not work as intended
- Why not showing all post by default in my jquery filter
- Remove Woocommerce product from cart with ajax/fetch
- WooCommerce Modal Fly cart on add to cart – With AJAX
- Word press – JSPDF – Sending PDF as attachment from wp_mail – Special characters
- Upload multiple files via ajax from an HTML file input
- How to pass javascript var to php var
- Ajax infinite scroll random order shows duplicate posts on custom post type