Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

update_post_meta Not Processing Array Data (Not Sure What I Am Missing)

$post_id is never defined in any of your update loops, and this shows that a simple single loop is not enough to achive this.

Since you are looping two concurrently created arrays, you would need to do something like this instead, using the index to match values:

for ( $i = 0; $i < count($post_ids); $i++ ) {
    update_post_meta( $post_ids[$i], '_metadescs', $metas[$i] );
}

Alternatively you could do a loop within a loop and match the index this way:

foreach ( $post_ids as $i => $post_id ) {
    foreach ( $metas as $j => $meta ) {
        if ($i == $j) {update_post_meta( $post_id, '_metadescs', $meta );}
    }
}

Related Posts:

  1. Remove item from post_meta array via AJAX
  2. WordPress AJAX load post metadata in modal
  3. Retrieve POST data from AJAX call
  4. WordPress Ajax always returns a 404 error
  5. problem with ajax and the path to the php page
  6. How to use wp_localize_script in a WordPress page other than functions.php?
  7. Real time Duplicate title check
  8. Load custom field value into div with AJAX
  9. Jquery ajax to custom php file: returning blank data
  10. Update WordPress Custom Field with AJAX on cached page
  11. Targeting single page with JS
  12. Click loads template via ajax
  13. Display notification only once
  14. How to retrieve the content (with a specific ID) via ajax by clicking a link tag
  15. ajax_object is not defined when ajax calls the function
  16. Returning a value from a PHP page
  17. Stumped – Ajax Response Returns 0
  18. Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
  19. Sending jsPDF documents to the server
  20. wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
  21. doing an ajax request always outputs 0
  22. Woocommerce add to cart quantity buttons with AJAX
  23. class click counter save number
  24. Checking for new message using AJAX and PHP. Server overload?
  25. AJAX request status 200 but no actual “response”
  26. wordpress count link clicks by ip address
  27. ajax, right way to do it and make it works?
  28. Ajax load more posts with multiple tax query
  29. WordPress Sending data to Ajax with select option
  30. Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
  31. Save Search System
  32. populate form fields in a loop with ajax
  33. dynamic dependent select dropdown
  34. Change “add to cart” button color based on Woocommerce product category [closed]
  35. Ajax request returns ‘Array’. How to output the actual results?
  36. Setting value of session with Ajax not working
  37. Show success or error messages in Ajax response to WordPress custom registration form
  38. How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
  39. Plugins not working on AJAX requests
  40. Fancybox type popup window that’s not an iframe
  41. How to disable controls in theme customizer?
  42. Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
  43. How do I Import / Upload Files with jQuery AJAX?
  44. Pull GetOption() variable into jQuery dynamically created html
  45. Unset session variable on page reload / setup but exclude AJAX
  46. Function won’t run onclick using Ajax
  47. WordPress plugin admin page – using WordPress function in linked php file
  48. A $_POST should occur when submit form but is not?
  49. jQuery Ajax PHP function call returning [object Object]
  50. Shortcode to pull posts
  51. Ajax search shows all results when user empties input?
  52. Why i can’t get custom fields value or post ID via Ajax?
  53. Get uploaded image and attach it to the new post
  54. Admin-ajax php not working on new wordpress version
  55. Add a counter for mouseovers (custom field)
  56. Accessing an API with jQuery and AJAX
  57. what does $options = get_option(‘test_theme’); do?
  58. Change Query Arguments (filter) with jQuery/Ajax or PHP?
  59. How to load previous or next attachment with jquery ?
  60. How to set variables with AJAX request to use in another function in WordPress
  61. Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
  62. Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
  63. Failed to load resource: the server responded with a status of 500 (Internal Server Error) through wp_admin_ajax.php
  64. Ajax result show in console if is called outside function and not showing in array
  65. Ajax filter with loadmore button
  66. Admin-ajax.php 404 error
  67. How to pass values from one function to the other using an array variable
  68. How to change PHP variables with AJAX request in WordPress
  69. Update $wpdb query with AJAX
  70. wp_ajax_ 400 Bad Request
  71. AJAX to add to cart multiple products woocommerce
  72. wp_set_object_terms returns 500 error when called through AJAX function
  73. How can i send id of the currently posted form data through json response in custom wordpress plugin?
  74. Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
  75. WordPress ajax filter returning all posts when it should be filtering by category
  76. Input field duplicates on form submit by jQuery
  77. How to echo a PHP code into WooCommerce variation product?
  78. How can i get the same ajax result using WP REST API instead of admin-ajax?
  79. defined (‘ABSPATH’) false after AJAX post to other PHP-file
  80. Find the method which AJAX GET calls
  81. AJAX Filter WHILE Loop not working WordPress
  82. WordPress 404 when using AJAX to call php function
  83. wordpress ajax pagination
  84. Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
  85. Submitting my form to the database and then redirecting to payment site
  86. Pass the updated value of aid from form using ajax
  87. How to run ajax in WordPress Post?
  88. 500 (Internal Server Error) of external php file
  89. Use jQuery and AJAX to get HTML
  90. Adding instant search to wordpress page
  91. Add php function into .js file (for tinyMCE button)
  92. Dynamic Gallery
  93. Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
  94. Jquery autosave text area after typing
  95. Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
  96. notify users when changed database
  97. getJSON response to PHP
  98. ajax problems on loading page [closed]
  99. Upload multiple files via ajax from an HTML file input
  100. custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget
Categories PHP Tags ajax, jquery, php, post-meta
Display of Custom Fields based on conditional if/and according to category/tag choice
NavBar Button Clicks (need 2 clicks rather than 1 click)

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress