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. How can I fetch loop of post titles via AJAX?
  4. Retrieve POST data from AJAX call
  5. Do I require the use of nonce?
  6. WordPress Ajax always returns a 404 error
  7. problem with ajax and the path to the php page
  8. How to use wp_localize_script in a WordPress page other than functions.php?
  9. Real time Duplicate title check
  10. Load custom field value into div with AJAX
  11. Security – Ajax and Nonce use [closed]
  12. Jquery ajax to custom php file: returning blank data
  13. Update WordPress Custom Field with AJAX on cached page
  14. Looking for a better way to handle an ajax script that pulls in post data on click
  15. Targeting single page with JS
  16. Can’t use get_results() in ajax query
  17. Use ajax to update_post_meta
  18. Problem with WordPress Ajax form
  19. Click loads template via ajax
  20. Display notification only once
  21. How to retrieve the content (with a specific ID) via ajax by clicking a link tag
  22. Access/update database with jQuery
  23. How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
  24. Passing jQuery value using Ajax to a page template
  25. ajax_object is not defined when ajax calls the function
  26. How to speed up admin-ajax.php in wordpress
  27. How to set variables with AJAX request to use in another function in WordPress
  28. Search Ajax Call – Use Form Data in Response
  29. Validating an email input from form field before submit using JQuery, AJAX, and PHP
  30. Why does PHP called with Jquery AJAX not allow additional php code to be added?
  31. WordPress cascading dropdown selection search based on Parent Page & Child Page
  32. Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
  33. Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
  34. Database entry removed on browser refresh, Ajax PHP jQuery
  35. jquery & ajax getting data from php in wordpress . admin-ajax.php returns 400
  36. Failed to load resource: the server responded with a status of 500 (Internal Server Error) through wp_admin_ajax.php
  37. How do I call a value from the datase using ajax
  38. Ajax result show in console if is called outside function and not showing in array
  39. Ajax filter with loadmore button
  40. Admin-ajax.php 404 error
  41. Where to add my PHP codes for AJAX Jquery to work?
  42. How to pass values from one function to the other using an array variable
  43. How to change PHP variables with AJAX request in WordPress
  44. How to use wp_ajax_set_post_thumbnail?
  45. Update $wpdb query with AJAX
  46. Can’t make lazy load for my site, help!
  47. How to reload a php script, using AJAX and jQuery
  48. wp_ajax_ 400 Bad Request
  49. AJAX to add to cart multiple products woocommerce
  50. wp_set_object_terms returns 500 error when called through AJAX function
  51. How can i send id of the currently posted form data through json response in custom wordpress plugin?
  52. Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
  53. WordPress ajax filter returning all posts when it should be filtering by category
  54. Input field duplicates on form submit by jQuery
  55. How to echo a PHP code into WooCommerce variation product?
  56. How can i get the same ajax result using WP REST API instead of admin-ajax?
  57. How to call a function from functions.php with ajax?
  58. Custom theme admin-ajax.php 400 (Bad Request)
  59. number of posts with “Load More”
  60. defined (‘ABSPATH’) false after AJAX post to other PHP-file
  61. Find the method which AJAX GET calls
  62. AJAX Filter WHILE Loop not working WordPress
  63. Ajax not updating to database
  64. WordPress 404 when using AJAX to call php function
  65. wordpress ajax pagination
  66. how use php query in AJAX jquery
  67. Ajax Load more CPT via shortcode
  68. Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
  69. Submitting my form to the database and then redirecting to payment site
  70. Pass the updated value of aid from form using ajax
  71. ajax form with multiple submit buttons and values
  72. How to run ajax in WordPress Post?
  73. 500 (Internal Server Error) of external php file
  74. Use jQuery and AJAX to get HTML
  75. Adding instant search to wordpress page
  76. Add php function into .js file (for tinyMCE button)
  77. Dynamic Gallery
  78. best way to communicate between php and jquery/javascript
  79. Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
  80. Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
  81. ajax form function error
  82. AJAX: WordPress filters inside $html do not work as intended
  83. Why not showing all post by default in my jquery filter
  84. Load Meta box value into div AJAX [duplicate]
  85. Jquery autosave text area after typing
  86. Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
  87. notify users when changed database
  88. getJSON response to PHP
  89. ajax problems on loading page [closed]
  90. Upload multiple files via ajax from an HTML file input
  91. Help with AJAX request
  92. I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
  93. custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget
  94. Help with uploading file with AJAX and PHP
  95. Help with creating commenting system using PHP, jQuery and AJAX
  96. Update shortcode values using ajax call
  97. ajax select parent show child in another select and show posts in another select-ajax filter search
  98. Add/Remove User Meta Array via AJAX
  99. How do I ensure that the URL parameters are updated correctly when multiple filters are applied
  100. Filtered queries not responeding to page path
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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