According to the database schema, the meta_value
is stored as longtext
. It is probably because of generic purpose. So, to obtain a numeric value. There are 2 parts for doing so.
Saving
Although it is storing as longtext, it is still good for preparing the rightful numeric format so that when retrieve it, it is likely to be expected value for conversion.
So, for checking before saving, may use is_float() or is_numeric() and so on to make sure the storing value is expected.
Retrieving
If the type float number is required to manipulate it correctly in the code after fetching the meta value from database. You may consider using php built-in function floatval() for float number to convert it before using. Another one is intval() for integer.
$meta_rwp_user_score['meta_rwp_user_score'] = floatval( get_post_meta(($anbieter_id),'rwp_user_score',true) );
// any text will be converted to 0
// manipulate as needed
Related Posts:
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- Job of meta_key meta_value fields in database tables
- order by multiple meta_keys?
- How to get the total number of meta_values based on a custom post type?
- WP_POSTMETA – What do these values mean inside the data structure?
- How can I convert postmeta from unserialized to serialized?
- why after saving meta value it’s saving all the values the one that i clicked?
- Is it safe to add a new field to meta_value field?
- How can I use ‘orderby’ => ‘meta_value_num’ to order by the numerical value even if the value starts with a word?
- Display current ranking of post as a number in post title
- I can not display meta value in extras.php and template-tags.php
- Count Post and Page Views based on meta_value Using Shortcode in Dashboard Widget
- Negative meta_query if storing multiple post_meta values with shared meta_key
- if get_post_meta function returns empty – Do Not Display HTML
- 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?
- Multiple meta key and value search in the query
- How to sort by meta value num, but ignore zero value?
- How to only display posts whose meta_value field is not empty?
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- Meta compare with date (stored as string) not working
- How to update/insert custom field(post meta) data with wordpress REST API?
- Front-end update_post_meta snippet displays white screen?
- How to get meta value in wp_attachment_metadata
- Clean up output added via wp_head()
- WordPress Admin Panel search posts with custom post meta values along with title
- Get post from meta_key and meta_value
- get_post_meta returns bool(false)
- How to get custom post type to display post meta on archive pages?
- WP_POSTMETA changes site crash
- meta_post_meta return value 1
- How to use post_id with a Class?
- Set default Custom Post Meta Value
- How to stop wp_postmeta from being called on archive and search pages?
- INSERT ON DUPLICATE KEY UPDATE failes in postmeta table
- Set Checkbox as checked by default
- replacing the_autor or make callback
- Some post meta fields stop saving after a few successful saves
- Save an array of values in the post meta box
- Custom post meta values reset by autosave [duplicate]
- get_post_meta() empty in preview WHEN custom post is published [closed]
- Add Embed.ly API objects to post_meta on update
- Editing does not change post_name
- Compare string with post id in wpdb and do stuff when match is found
- $wpdb class updating meta_value using Ajax [closed]
- How to selected which tags to print, instead of printing the whole tag list?
- query posts and split meta information into separate div’s
- add unique string as custom-field to every post
- How do I insert a new meta key / value pair, but only if another meta key is present?
- “Cannot use import statement outside a module” JS error while adding a custom meta block?
- Gutenberg featured image checkbox – checkbox not correctly set on editing page reload
- How to properly use oneOf and anyOf in Rest Schema?
- Print specific values stored in a post meta array
- Get the author meta adds now
- wordpress is_front_page() issue
- show ad after # paragraphs
- If ACF meta_key has meta_value
- How we can get “get_post_meta” of specific user who added it
- Change wordpress meta tag description using WP functions
- Repeated nav bar queries failing to be cached
- Randomizing Post Links Outside of Loop – No Author or Date
- help to decipher wp metadata
- Cant create or update meta fields using WordPress REST API
- Filter posts by meta key
- Insert Custom Field Value
- SQL query – get a featured image’s alt / alternative text
- update_post_meta() updating nested array in Multidimensional array with empty sub-array
- How do I list taxonomies that have upcoming events in WP? Is there a way to do this without having to query posts first?
- Sorting my posts on homepage my specific value in post_meta table
- Strict comparisons problem when using boolean post meta
- Why is the actual number of thumbnail images not matching what is store in an attachments metadata?
- How to use multiple Meta Field from CPT as Post permalink
- Set class if a meta value is set within post archive
- If I disable screen options, does WP still try to update post meta?
- update_post_meta not working with transition_comment_status
- Can we have duplicate key pair values in post meta data?
- I created a Custom Meta Box but it is not displaying the value on my post page
- Meta data being pulled from wp-login.php
- Attachment metadata has value of ‘1’
- Get post content before rendering
- wp_insert_post inside save_post adds wrong metadata to inserted post
- Rename image filename using ‘media_handle_upload’
- Update Post metafield of specific categories
- Using Self Hosted Video URL With Custom Fields
- Multiple postmeta values to the same post_id/meta_key combination?
- get_post_meta not work in php foreach
- Why are my custom metaboxes not updating the post meta?
- Problem serializing single quote and double quote into post meta
- Storing post_meta fields in array
- Performace on 1 million plus meta fields vs 1 field with 1 million multi array
- Hide the_meta if no value
- Fetching array of postmeta with $wpdb and in_array conditional
- Piklist File Upload
- how to echo/display the custom field value in specific custom field name?
- update_post_meta() not working in bulk option
- How to update the ‘modified_time’ of a post ONLY when content is changed?
- Custom Field: Display only if a specific key is selected outside the loop
- Media library orphans
- Multiple If else statements on Search Result Page
- get_children filter with postmeta