Try this, your code may be returning an empty string or false, then comparing it to another empty string or false thus returning true.
function check_post_update_meta ($post_id, $key, $value) {
// response can receive post meta array, or '' or false
$response = get_post_meta($post_id, $key, true);
// isset checks for data, so in case $response is empty if() will not evaluate true
if( isset($response) ){
if ($response == $value) {
return true;
} else {
$response = update_post_meta($post_id, $key, $value);
}
}
}
Related Posts:
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- Advanced search form with filters for custom taxonomies and custom fields
- Meta query with boolean true/false value
- Custom field values deleted when trashing custom post type
- Custom Post type – how to get checkbox to update meta field to null
- How do I Paginate Search Results for Custom Post Types?
- Ordering posts having multiple post-meta date fields
- How do I remove all the metaboxes for a custom post type?
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
- Grossly inefficient wordpress loops!
- How Do I Use WP_Query to Run This Database Query as Search Result?
- WordPress Admin Panel search posts with custom post meta values along with title
- Rest Api v2 orderby meta_key in custom post type
- Custom post type category not displaying in custom post type
- How to make custom post meta wp_editor translatable?
- How to add multiple featured image in meta box in post editor?
- update_post_meta() whenever custom post type is updated
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- How to best delete orphan wp_postmeta
- How can I get_post_meta() in the most efficient way?
- Count posts with specific term_meta
- Custom search for custom post meta with pre_get_posts interferes with WP search
- WordPress Orderby Numeric Value Not Working
- Replace title column in post list with post meta value
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- List all images from a single post meta value
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Insert Multiple Post with Same Publish Button
- Undefined Variable – Custom Post Type Meta
- Ordering posts in Search & taxonomy by post_meta
- Meta Key Value in current-user-only loop
- How to implement a Google map store locator
- Post image in WordPress not appearing on home page
- changing meta value and meta key of price field
- Posting to a Custom Post Type from front end – user generated content
- Update Post Meta for a logged in user
- Getting meta in editor plugin, and event triggering issue
- Restrict Access to Posts based on Custom User and Post Meta Data
- get_post_meta returning no value in custom post type alert email
- Metabox not show in categories custom post type cmb2
- Importing Data from a Non-WordPress database, into WP
- List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Filter date from post meta when date is in string format
- Get only used meta_values
- Get $post->ID from a URL
- Displaying a div from an assigned meta_value when on a page
- Setting Post Title via Meta Data returns Auto-draft
- Values from meta-box not on $_POST
- Returning a custom content types with meta values
- Custom post type suddenly stoped working after WordPress 5 update
- How to show custom field on specific custom post type posts only when filled
- is_main_query() never called on WP 4.4
- How can I output WPAlchemy repeating fields meta values in my page template?
- Meta box data not saving
- Related posts meta_query CPT
- Meta box with front-end styling
- How can I get some of a posts meta data whilst it is still inserting?
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- Cannot Save MetaBox Data in Custom Post Type
- best way to use custom taxonomy, post type and meta in a job system
- Say I have a tech blog, how best would I store technical specs for a phone, if i use custom post types
- How to order custom posts by one of the custom fields value, ‘date’?
- Hide title field of selected post-types on edit pages
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- How to create review point system for CPTs (many-to-many relationship)
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- Save data is post using php front end
- How to keep custom post type related information
- Can’t save meta box data in WordPress using custom post types
- Creating a custom post type upon registration for a specific user role
- How to sort by multiple values in a nested WP_Query
- Where is get_post_meta value located?
- How can I use a custom template to load custom post type posts based on a post_meta value
- How do I create a customised table list of a custom post type (in the admin area)?
- How to properly get the wp_postmeta.meta_value of a custom post type in specifics?
- How to save post_status using action save_post?
- Custom post meta box as a sub form
- Metaboxes in Loop
- Custom meta box data not saving
- Collect custom post in a calendar
- Storing data in a multidimensional array from dynamically generated foreach loop
- How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
- meta query always fails even if data is correct
- Values inside a custom field to determine which category posts to display
- Display a post count from a custom metabox selection
- How to rewrite CPT-Permalinks the correct way (incorporating meta-box-data)?
- Custom post type submenu sorted by specific meta_key & meta_value
- Advanced search form with filters for custom taxonomies and custom fields
- Querying meta values within an array
- Post AND page parameter for WP function
- why get_post_meta is returning 0?
- Save post_parent in a custom post type
- How to display Author Profile based on Custom field value
- Automatically add custom taxonomy when meta value gets to a set number or beyond
- Display a list of posts whose meta field values are equal to the ID of the post being viewed?
- Check for custom field value in different post type than current one and do something
- I am having a problem with fetching product data in the Gutenberg block editor