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_keysreturns $_POST array keys obviously.array_filterfilters out only numeric keys (see anonymous function).includeoption ofget_brands()allows you to specify exact ids of terms you require.
Related Posts:
- username_exists() function can’t be access without logging in
- Do I require the use of nonce?
- Security – Ajax and Nonce use [closed]
- 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
- 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
- Access/update database with jQuery
- Passing jQuery value using Ajax to a page template
- How to set a custom path, for ajax image upload folder in admin?
- admin-ajax.php responding with 0
- ajax_object is not defined when ajax calls the function
- Page Reloads Before AJAX Request Finishes
- Why is this Ajax not working?
- How to prevent those PHP variables from being cached on WordPress?
- Use ajax from function.php
- Ajax return code 400
- get post based on category chosen in drop down – The ajax method
- How to make drop down post title
- Create onClick Event to Re-load a Widget
- ajax, right way to do it and make it works?
- How to store data from multiple forms using ajax and php
- WordPress ajax doesn’t display object method on jQuery .change() function
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- Problem with custom plugin using AJAX to pull info from php file
- Gutenberg block – Save PHP function’s output as HTML?
- Call a PHP Function with Multiple Parameters that is outside the AJAX Handler
- Ajax date_query not working past the first iteration
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- WordPress, AJAX and pre_get_posts using conditional tags
- Refresh table data with Ajax
- Setting value of session with Ajax not working
- [jQuery]Adding shortcode
- Display parent and child taxonomies in separate drop down select fields
- Using Select HTML in Bootstrap Popovers
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
- Pull GetOption() variable into jQuery dynamically created html
- Load Posts on Click via Ajax into a DIV
- Use value from Ajax call in PHP function
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- Get related product based on subcategory selected from category id with ID 142
- A $_POST should occur when submit form but is not?
- Shortcode to pull posts
- WP_Query with AJAX returning empty array
- How to get post category list as select in front-end?
- PHP: How to access db the right way in plugin?
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Can not call .php files after switching to %postname%
- WordPress Conditional / Multiple Taxonomy Query
- How to use wp_send_json() and output the value with ajax?
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- AJAX function running TWICE with WordPress admin-ajax.php
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- WordPress Search Ajax + Isotope + InfiniteScroll
- Is it possible to access admin-ajax.php using PHP?
- Multiple AJAX handler functions conflict in functions.php
- How to call my PHP function with AJAX ? wp_query
- Can’t pass var from php wp_ajax into ajax script : result undefined or null
- Admin-ajax.php 404 error
- How to pass values from one function to the other using an array variable
- How to change PHP variables with AJAX request in WordPress
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?
- get_the_author_meta( ‘ID’ ) just return 1
- custom mailchimp form using HTTP API
- WordPress is setting from header wrongly in wp_mail
- Cannot transfer ajax post data from js to php file
- wordpress dependent dropdownlist using post type is not working
- Input field duplicates on form submit by jQuery
- ajaxurl usage for a custom function
- How to echo a PHP code into WooCommerce variation product?
- Custom Post type Ajax search results
- Ajax wordpress function showing source code in alert and not value of input field?
- Singleton in plugin fails on AJAX call (Plugin initialzed again)
- Prepared DB Query from _POST array
- Find the method which AJAX GET calls
- Code works on page-example.php by not category-example.php
- Retrieve $_POST data to send to javascript without using localize script
- wordpress ajax return 0
- Modify category archive page loop on functions.php
- Run insert if no entry otherwise run update with ajax
- How to run ajax in WordPress Post?
- Adding instant search to wordpress page
- Add php function into .js file (for tinyMCE button)
- WP_Query based on another query on the page
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- Load php function with AJAX on modal window
- send meta box input data without publish button
- WordPress Query -> Ajax Query
- how to display tables via ajax
- How to Set Page Pagination Using Ajax JQuery – WordPress
- How to pass and validate nonce in custom REST routes
- ajax problems on loading page [closed]
- Woocommerce – Include custom user meta in order ‘filter by registered customer’ Ajax search
- Start a long running PHP process via JS/Ajax and monitor progress on admin page
- custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget
- How to make this shortcode not refresh the whole page when i use it on frontend