you have pass static postID which is not match at your live server. Please check the ID of post. For good practice pass the dynamic ID as per documentation.
<?php add_post_meta($post_id, $meta_key, $meta_value, $unique); ?>
$post_id –> The ID of the post to which a custom field should be added.
$meta_key –> The key of the custom field which should be added.
$meta_value –> The value of the custom field which should be added. If an array is given, it will be serialized into a string.
$unique –> Whether or not you want the key to stay unique. When set to true, the custom field will not be added if the given key already exists among custom fields of the specified post.
Or try this logic
<?php
if ( ! add_post_meta( 39, 'overall', 4, true ) ) {
update_post_meta( 39, 'overall', 4);
}
Related Posts:
- How do I retrieve the slug of the current page?
- Lack of composite indexes for meta tables
- How we get_post_meta without post id
- What is the code to get the download link for a product in WooCommerce?
- Content hooks vs User hooks
- Adding an assisting editor box to Post page
- Get Advanced Custom Fields values before saving [closed]
- Why am I getting an infinite loop with have_posts?
- get_post_meta – get a single value
- How to store post meta in an array?
- get_post_meta / update_post_meta array
- update_post_meta() not working when used with WordPress action
- Triple meta_key on custom SELECT query
- update_post_meta not adding anything.(Nor add_post_meta)
- Get posts by meta value with date
- Identifying Importer Posts
- Get updated post meta on save_post action?
- Delete post meta conditionally after save post
- How to sanitize post meta field value?
- Job of meta_key meta_value fields in database tables
- Post IDs missing on delete_postmeta action hook
- How to store Gutenberg ColourPicker RGBA as metadata
- Is it possible to update a post meta field through REST API if the format of it when registered is nested?
- How trigger to save post when updating post meta
- Query 2 meta key values and a category
- trying to do if post meta !=0
- Trying to get file name
- how to build (custom) stats for post views, per month
- get_post_meta pagination
- Removing Post Meta from Category Pages?
- Hey, I want the second options. get_post_meta()
- Update post meta in woocommerce order frontend
- echo image caption
- get_*_meta doesn’t always return an array
- populate post meta in gravity forms [closed]
- Generate multiple goo.gl shortlinks for qtranslate bilingual blog
- How can I convert postmeta from unserialized to serialized?
- How to display post view count by date, week and month?
- How can I filter posts when the meta_value is a serialize object?
- Get User Post if Private
- How to receive all the meta information of a post ?
- Unknown characters added to meta data values
- Compare old meta with new post meta
- get_post_meta($post->ID) returns empty string when in preview mode of custom post type
- need to add add user names to the post for later retrieval or removal
- Like & Dislike functionality using JavaScript
- How can I change the tag contents of individual WordPress posts?
- get_post_meta producing white screen of death
- get_permalink vs the_permalink
- Look up all posts by status or meta value – performance difference
- Updating my Post when expiry date is past
- How to remove Date from Meta Description on SERP?
- Can A Post Meta Field Store multiple values that are not in an array?
- esc_attr on get_post_meta [closed]
- How to display sql query fired by posts_where
- Unfiltered html with update_post_meta
- get meta value from page query
- Sort custom posts in archive by multiple values: date AND meta key
- why after saving meta value it’s saving all the values the one that i clicked?
- Retrieving post meta array (attachment)
- Get posts ordered by meta data
- Why is variable that get_post_meta stored in empty?
- Stop `update_post_meta` from working each time page refreshes?
- Displaying values from related field – if empty shows current post type’s link and title
- get_post_meta inside echo [closed]
- WordPress postmeta: Store data as an array or single item?
- Display Post Meta in Header
- get_post_meta in one post only
- Custom fields or something else
- wpdb->get_var – count author posts, meta value
- Search post overlapping dates – meta_query with meta_key
- Post Publish date not display on Umaya Child themes
- How to merge the database results into single result?
- I want to Add Feedburner Right After Meta Details
- How can I update this array built from post meta data?
- if get_post_meta function returns empty – Do Not Display HTML
- Custom column on CPT not showing correct value when meta data not set
- How to access post meta on the first time a post is published
- How to get the total of two meta values from different meta keys?
- How to update/add child posts meta whenever the parent post meta is updated?
- Get or set values in post meta
- How to query post with meta?
- update_post_meta() throws Uncaught error: Cannot create duplicate attribute
- Display multiple meta_key/meta_values by single SQL query
- show user based on user_meta
- Meta keys won’t add using wp_insert_post
- How do you sort the items in a custom taxonomy meta box?
- post_title in save_post action
- Twenty Twelve entry meta data – change and move
- Getting meta content from get_next_post & get_previous_post
- How can I prevent the post_modified column in wp_posts from being updated?
- How to get pictures of the WordPress post
- When importing posts to a new site if XML file has postmeta not setup on new server what happens?
- Get value from post meta array, and add it as a category
- Access Serialized Post Meta Values
- Does post-meta belong in header?
- WP-API : post_meta not updated… but have another entry
- Parse error thrown by get_post_meta [closed]
- How to get all the related ids without array?
- Remove action of an external plugin after checking if custom post meta is set