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 wp_postmeta table based on 2 keys

Yes, there is.

These are some WP functions to get, add and update post meta values:

get_post_meta()

add_post_meta()

update_post_meta()

Your code could be:

$meta_value = (int) get_post_meta( $post->ID, 'meta_key', true );
update_post_meta( $post->ID, 'meta_key', $meta_value + 1 );

Related Posts:

  1. Add options to featured image
  2. Change meta tags programatically
  3. Use a function to update post meta based on other post meta
  4. update_post_meta for custom field not working upon form submission
  5. Most efficient way to get custom database records from 20 buttons and 20 tables?
  6. Assign category using custom field?
  7. How to update BuddyPress xprofile fields programmatically? [closed]
  8. Convert User ID’s to User Names in a single.php file
  9. Best Practice for Syncing Local Development With Staging Development [closed]
  10. Is it good practice to use wpdb->query() function?
  11. Check if row exists before inserting
  12. Remove the deleted users avatar from list
  13. when I fetch data from remote mysql database in wordpress built in wordpress function is not working?
  14. Can’t check if a post has thumbnail adding filter to get_post_metadata()
  15. WordPress shortcode attributes for database SELECT?
  16. Move Post to different category if post_meta field is 0 or is 2 days old?
  17. Updating Media Published Date When Parent Post Is Modified in WordPress
  18. What WordPress function to use to get meta value by using meta keys?
  19. Default Custom Field Value Automatically Update
  20. Get User Login Data (date, time… )
  21. Multisite 404 on pages – rewrite error breaks database
  22. Post meta not updating
  23. Function to update post_meta based on existing post_meta
  24. Accessing two databases wordpress
  25. Connecting to a 2nd DB gives me no results when querying
  26. Exclude from the query posts with meta_key and meta_value
  27. Is There Any Built In WP Functionality For Combining Form Fields To Return Specific Data
  28. Prevent custom field from being updated after first publish
  29. Get array of metakey in all posts
  30. User function to return multiple get_post_meta()
  31. What are the meta fields for an attachment?
  32. Check if a value exists in database table
  33. wp_usermeta – Read from database, but save function broken
  34. How to avoid saving empty data to sql while using add_meta_box
  35. How to change text color depending on the number value (Using javascript)
  36. How to loop while adding data to database?
  37. How to add custom metakey to shop_order page’s searching function?
  38. How can I connect to a second database and still be able to use wp functions like get_post_types()?
  39. Writing a function for WP Cron to run a SQL command daily
  40. blank page with wp_get_attachment
  41. Reference multiple style sheets, clearing styles for permalink page, custom fields for css
  42. Button click counter for login user
  43. How To Display Author Popup on Entry Meta (Genesis Framework)?
  44. Creating a “Related Meta” type field?
  45. Function stops working
  46. Remove post from latest posts after a month only with certain tag
  47. save_post doesn’t correctly process function call with php class
  48. Return ACF Field value function
  49. Database SQL Error, Should Work
  50. Database Query not working
  51. update_post_meta not working in function
  52. How To Get WordPress Categories Last Update Date?
  53. How to add a meta information to the URL?
  54. Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
  55. Function to get the name in database table from the comma separated string
  56. update_post_meta after form is submited
  57. Add custom fields after post/page title
  58. Functions file mods and CPU
  59. Display post_meta-by_key on product catalogue
  60. How to save custom made object in an array in a post meta field
  61. Adding and updating repeating custom field meta data
  62. Bulk set Post Title as Tag where Tag is Empty Function
  63. How to trigger an update_option
  64. Missing feature image link function
  65. What’s the difference between home_url() and site_url()
  66. Remove “Category:”, “Tag:”, “Author:” from the_archive_title
  67. get_template_directory_uri pointing to parent theme not child theme
  68. How to customize the_archive_title()?
  69. remove empty paragraphs from the_content?
  70. What is the “with_front” rewrite key?
  71. Why use if function_exists?
  72. Post meta vs separate database tables
  73. How to override parent functions in child themes?
  74. wp_enqueue_script was called incorrectly
  75. Add multiple custom fields to the general settings page
  76. Ajax call always returns 0
  77. 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
  78. How long does a deprecated function live in core?
  79. Solution to render Shortcodes in Admin Editor
  80. How to add a data attribute to a WordPress menu item
  81. What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
  82. remove_action on after_setup_theme not working from child theme
  83. plugins_url vs plugin_dir_url
  84. Remove type attribute from script and style tags added by WordPress
  85. How to run a function every 5 minutes?
  86. Best way of passing PHP variable between partials?
  87. Upload Multiple Files With media_handle_upload
  88. How to display custom field in woocommerce orders in admin panel?
  89. Why WordPress choose data serialization over json_encode?
  90. Adding fields to the “Add New User” screen in the dashboard
  91. Issues with title-tag and document_title_parts
  92. How do I get the current edit page ID in the admin?
  93. How to check if a user exists by a given id
  94. Why isn’t is_page working when I put it in the functions.php file?
  95. Add tags to the section via functions.php
  96. Add image size if page template
  97. How to create a custom order status in woocommerce!
  98. Remove Actions/Filters added via Anonymous Functions
  99. Adding a second email address to a completed order in WooCommerce [closed]
  100. How to load parent_theme functions.php before child_theme?
Categories functions Tags database, functions, post-meta
Bootstrap slider not working
SSL not working fine, Home url not matching with site url wordpress errors

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