Yes, there is.
These are some WP functions to get, add and update post meta values:
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:
- Add options to featured image
- Change meta tags programatically
- Use a function to update post meta based on other post meta
- update_post_meta for custom field not working upon form submission
- Most efficient way to get custom database records from 20 buttons and 20 tables?
- Assign category using custom field?
- How to update BuddyPress xprofile fields programmatically? [closed]
- Convert User ID’s to User Names in a single.php file
- Best Practice for Syncing Local Development With Staging Development [closed]
- Is it good practice to use wpdb->query() function?
- Check if row exists before inserting
- Remove the deleted users avatar from list
- when I fetch data from remote mysql database in wordpress built in wordpress function is not working?
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- WordPress shortcode attributes for database SELECT?
- Move Post to different category if post_meta field is 0 or is 2 days old?
- Updating Media Published Date When Parent Post Is Modified in WordPress
- What WordPress function to use to get meta value by using meta keys?
- Default Custom Field Value Automatically Update
- Get User Login Data (date, time… )
- Multisite 404 on pages – rewrite error breaks database
- Post meta not updating
- Function to update post_meta based on existing post_meta
- Accessing two databases wordpress
- Connecting to a 2nd DB gives me no results when querying
- Exclude from the query posts with meta_key and meta_value
- Is There Any Built In WP Functionality For Combining Form Fields To Return Specific Data
- Prevent custom field from being updated after first publish
- Get array of metakey in all posts
- User function to return multiple get_post_meta()
- What are the meta fields for an attachment?
- Check if a value exists in database table
- wp_usermeta – Read from database, but save function broken
- How to avoid saving empty data to sql while using add_meta_box
- How to change text color depending on the number value (Using javascript)
- How to loop while adding data to database?
- How to add custom metakey to shop_order page’s searching function?
- How can I connect to a second database and still be able to use wp functions like get_post_types()?
- Writing a function for WP Cron to run a SQL command daily
- blank page with wp_get_attachment
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- Button click counter for login user
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Creating a “Related Meta” type field?
- Function stops working
- Remove post from latest posts after a month only with certain tag
- save_post doesn’t correctly process function call with php class
- Return ACF Field value function
- Database SQL Error, Should Work
- Database Query not working
- update_post_meta not working in function
- How To Get WordPress Categories Last Update Date?
- How to add a meta information to the URL?
- Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
- Function to get the name in database table from the comma separated string
- update_post_meta after form is submited
- Add custom fields after post/page title
- Functions file mods and CPU
- Display post_meta-by_key on product catalogue
- How to save custom made object in an array in a post meta field
- Adding and updating repeating custom field meta data
- Bulk set Post Title as Tag where Tag is Empty Function
- How to trigger an update_option
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- remove empty paragraphs from the_content?
- What is the “with_front” rewrite key?
- Why use if function_exists?
- Post meta vs separate database tables
- How to override parent functions in child themes?
- wp_enqueue_script was called incorrectly
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- How long does a deprecated function live in core?
- Solution to render Shortcodes in Admin Editor
- How to add a data attribute to a WordPress menu item
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- remove_action on after_setup_theme not working from child theme
- plugins_url vs plugin_dir_url
- Remove type attribute from script and style tags added by WordPress
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- Upload Multiple Files With media_handle_upload
- How to display custom field in woocommerce orders in admin panel?
- Why WordPress choose data serialization over json_encode?
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- How do I get the current edit page ID in the admin?
- How to check if a user exists by a given id
- Why isn’t is_page working when I put it in the functions.php file?
- Add tags to the section via functions.php
- Add image size if page template
- How to create a custom order status in woocommerce!
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]
- How to load parent_theme functions.php before child_theme?