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. Trying to GET data with ajax from database and show in fullcalendar
  54. Custom field values to taxonomy terms
  55. Not connecting to database in file with multiple MySQL connections
  56. Way to bulk make all my tags lowercase?
  57. $Wpdb post meta query is not working with mutliple meta keys and values? [closed]
  58. HTML escaping data with ajax requests
  59. Display custom field on 404 page outside loop
  60. php include not working in custom page
  61. update_post_meta only updating on last loop of foreach
  62. Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
  63. Get related product based on subcategory selected from category id with ID 142
  64. add category to posts with tag wordpress
  65. How can I Use 2 databases with one WordPress install
  66. Is there a hack for using is_page() within the function.php file?
  67. Why won’t this wpdb get_results query return results?
  68. Submit form to db
  69. Can not call .php files after switching to %postname%
  70. WordPress Conditional / Multiple Taxonomy Query
  71. WordPress low speed after migrating to new host
  72. WordPress Search Ajax + Isotope + InfiniteScroll
  73. How to call my PHP function with AJAX ? wp_query
  74. AWS Lightsail WordPress – connect to database on instance using mysqli
  75. No more get_option(‘date_time’) in WordPress 5.5?
  76. get_the_author_meta( ‘ID’ ) just return 1
  77. Using wpdb to connect to a different database is not working
  78. WordPress ajax filter returning all posts when it should be filtering by category
  79. Store custom field’s multiple values in one user meta key
  80. WooCommerce multiple custom fields code
  81. Insert data from form to database
  82. Post Meta statement?
  83. WP_query meta_query slow with OR and DATES
  84. Pass form attributes to another php template in wordpress
  85. meta field for numerous links
  86. Custom HTML form using PHP – help with ajax/username validation
  87. AJAX Returning Way Too Many Posts
  88. Conditional statement within WP SQL query
  89. Modify category archive page loop on functions.php
  90. two wordpress sites, two themes, one database, same content
  91. how to check for wordpress Query errors
  92. Showing custom field contents without listing description
  93. Custom query_posts() parameter
  94. AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
  95. How to add together (get the sum) a field from all author’s posts
  96. Load php function with AJAX on modal window
  97. Query Concatenation
  98. Error resetting database index using ALTER TABLE in $wpdb->query
  99. ajax problems on loading page [closed]
  100. Shortcode Displays 2 times
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
  • 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