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

Use ajax to update_post_meta

That will not work because you are referring to a single php file, instead the the whole WordPress environment.

There’s a easier way to use ajax in WordPress.

Use admin_url('admin-ajax') as the form action, then put the function that will answer the ajax call in the theme’s functions.php.

More detail here in this answer

Related Posts:

  1. How to update custom fields using the wp_insert_post() function?
  2. How to display multiple Post meta_key/meta_values by SQL query
  3. How to use multiple query with same meta key
  4. simple wordpress ajax plugin not working when not logged in
  5. Jquery ajax to custom php file: returning blank data
  6. Update WordPress Custom Field with AJAX on cached page
  7. How can update custom meta for all posts
  8. Is the regular ajax request method safe or I should use admin-ajax.php?
  9. AJAX in WordPress, sending coords data to MySQL and show after into map
  10. WooCommerce: update custom fields after checkout validation failure
  11. how to increase custom post value by one most efficiently?
  12. Ajax $wpdb not returning table data
  13. Checking for new message using AJAX and PHP. Server overload?
  14. How can I create a list of page titles from custom meta values?
  15. Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
  16. How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
  17. Refresh table data with Ajax
  18. Is it possible to retrieve all posts with a certain value for metadata?
  19. Non-Closing PHP Query in WordPress Loop
  20. how to get serialized post meta
  21. WordPress loop by meta key that is an array? and how loop multiple arrays
  22. A $_POST should occur when submit form but is not?
  23. How to store multiple custom meta box
  24. Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
  25. How to use AJAX in WordPress in MYSQL query?
  26. Order a WP_Query by meta value where the value is an array
  27. Live search from database table
  28. Processing ajax call to php to insert into mysql database
  29. Add a custom class to the body tag using custom fields
  30. Define category ID using get_post_meta
  31. Add a counter for mouseovers (custom field)
  32. Hide a div when a custom field is empty
  33. WordPress stripping out custom field tags
  34. Using Ajax to submit a form, and run a SQL Select query based on user input from the form
  35. Order category posts by last word of custom field
  36. Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
  37. How to update custom fields when post is published?
  38. What is the correct way to search 3 custom fields only in WordPress?
  39. update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
  40. autocomplete in wordpress using ajax with json-data
  41. WP post meta – for loop inside for loop
  42. Remove item from post_meta array via AJAX
  43. When working with a post, almost all wp_postmeta are deleted
  44. Updating Lat and Lng of posts automatically gives sporadic results
  45. Prepared DB Query from _POST array
  46. Ajax not updating to database
  47. WordPress AJAX load post metadata in modal
  48. Include a custom field in mysql query
  49. MySQL query in WordPress with AJAX
  50. retrieve wordpress post-meta using php not wordpress functions
  51. If custom field doesn’t exist, or exists and it’s true show title?
  52. Metadata on the WP_Post object
  53. Help with creating commenting system using PHP, jQuery and AJAX
  54. Trying to GET data with ajax from database and show in fullcalendar
  55. MySQL Query that looks for post with Custom Field, then changes Category
  56. How to run JS, PHP and etc. inside WP post?
  57. Why is variable not working on custom sql query using wpdb?
  58. Trying to implement Ajax comments in WordPress, getting WP error
  59. How to test nonce with AJAX – Plugin development
  60. Can’t search posts using WP_QUERY inside AJAX Function
  61. Show MySQL errors that occur when I excute $wpdb->insert()
  62. Woocommerce add to cart quantity buttons with AJAX
  63. Importing hard coded custom field into acf field
  64. Why is the post meta[] empty when I make a call to the wordpress rest api?
  65. Get Current User Id Inside a Loop Returns 0 For a Shortcode
  66. class click counter save number
  67. Get WooCommerce product details and transfer them to a custom DB table
  68. Random order of WP_Query results with highest meta value
  69. tracking number field in Woocommerce order [closed]
  70. Any possible way to make $wpdb->get_results() return anything else than array?
  71. Is XAMPP faster than running LAMP in WSL on Windows 10? [closed]
  72. Remove one value in dismissed_wp_pointers?
  73. get post based on category chosen in drop down – The ajax method
  74. Why is $_REQUEST an empty array in admin-ajax.php?
  75. WordPress Site Running Extremely Slow on Dedicated Server
  76. How can I export posts with featured images, without download them
  77. AJAX request status 200 but no actual “response”
  78. get current custom post ID by WP_Query method
  79. How to make drop down post title
  80. Ajax not working es expected (Returns 0)
  81. Create onClick Event to Re-load a Widget
  82. How to securely provide a $_POST var in WP_Query with PHP 7?
  83. The text box have space character
  84. how to remove metadata from the posts of my blog?
  85. Can’t get wp_insert_post to work
  86. Load a page into a div with Ajax
  87. Trying to remove post thumbnail with plugin
  88. Creating a Multi-Level Associative Object Using AJAX
  89. Accessing data from a non-WP database/table within a page content
  90. Randomly Assign an Image’s Alt Text Based on Data From Post
  91. Create WP_Query to search for posts by their categories or their parent/child categories
  92. What is a valid parent for get_terms()?
  93. Passing the custom field values in the wp_get_current_user array function
  94. Get updated query results on page after insert in database
  95. WSoD being caused by this piece of code
  96. wordpress count link clicks by ip address
  97. Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
  98. Sort posts by custom fields value using dropdown menu
  99. Ajax – Call to undefined function get_option()
  100. I want to select the from values from database in WordPress? [closed]
Categories PHP Tags ajax, custom-field, mysql, php, post-meta
Having a lot of difficulty getting add_editor_style() to load into source code
How to Change BuddyPress Mystery Man Graphic without Overwriting Core Image File [closed]

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