You can filter generated SQL and add precision parameters that you need.
Enable filters for get_posts()
by adding following to query:
'suppress_filters' => false,
And:
add_filter('posts_where','cast_decimal_precision');
function cast_decimal_precision( $where ) {
return str_replace('DECIMAL','DECIMAL(10,3)',$where);
}
Update
With Jan’s suggestion:
add_filter('get_meta_sql','cast_decimal_precision');
function cast_decimal_precision( $array ) {
$array['where'] = str_replace('DECIMAL','DECIMAL(10,3)',$array['where']);
return $array;
}
Related Posts:
- WP Query post meta value
- get_post_meta slowing down my page load (in a plugin)
- Woocommerce: order posts by meta key
- When to use WP_query(), query_posts() and pre_get_posts
- How to only display posts whose meta_value field is not empty?
- WP_Query vs get_posts
- Order by optional meta key?
- Get posts from Network (Multisite)
- Reduce or prevent calling of update_meta_cache
- Get Recent Posts by Date in Multisite
- How-to exclude terms from the main query the most performant way?
- Query all posts where meta value is empty
- Query Custom Meta Value with Increment
- WP-CLI How to generate a list of posts with corresponding meta values
- Get_post() with meta_key when compare is a date
- get_posts not finding argument: post_name
- How to count post meta key values for all posts in database
- What should I use, get_posts or wp_query for less CPU load?
- How should I use posts_where to change meta_value from a string to integer?
- How to get post from all Blog Multisite to the Main Site?
- WP Meta Query for some meta (array) values
- query posts in functions.php and update a field
- get_posts() seemingly ignoring post_type
- Can not switch the queried post in pre_get_posts hook
- how to fire join query with post_meta
- Count posts returned by get_posts in external PHP script
- WP_Query, custom sort and custom filter
- SELECT * FROM $wpdb->posts WHERE ID > 160
- Adding multiple post queries with parent and children to page – Best Way
- Minimising Database Queries when using Advanced Custom Fields
- Pull post meta with post_query?
- get_posts – get all posts by array of author
- Create a sitemap without a plugin – get parent pages only?
- Creating a custom search for a specific post type
- get_posts – find out if querystring was crap and fallback is used
- Creating query to show which editor (classic or block) was last used to edit a post/page
- get_posts() not working with multiple statuses
- Inserting serialized value into wp_postmeta using update_post_meta
- Return only post(s) which have post_excerpt
- Performance when getting post meta for post retrieved by meta value
- Display custom field meta outside loop, site wide
- WP_Query() and get_posts() can’t handle over a thousand posts?
- how to make members list directory through wordpress post custom meta key.
- How do I query for posts by partial meta key?
- Conflict with get_posts and the_content
- WP_Query post_parent parameter always returns children of current page
- New WP_Query loop in admin causes problems
- echo a specific meta_key queried through a custom post
- How to increase load time of an archive/search page (WP_Query)
- How to show more post at a given category?
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- Hide posts with meta key in WP_Query
- Filter posts by comparing custom meta value against postdate
- WP_Query – Accessing MetaValue from Query Result
- get_posts output always same post
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- “paged” in WP_Query returns 0 posts
- Specify strict ‘order by’ in WordPress query
- get_posts() and global variables
- search serialised meta_value for date value?
- Check if searched number is within the post meta value
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- Order WP_Query results by meta key value in custom query
- Nested array issue in meta_query
- How to get posts by category and by choosing a taxonomy term?
- Function using get_posts() with tax_query not working when called from functions.php
- Search for pages with permalink
- Execute PHP function inside the admin area
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Why my query is not “Main_query”?
- Facing problem with tax_query results
- Populate select list with meta values from all posts of a Custom Post Type
- Form checkbox value going to dynamic URL
- show most viewed post
- Display posts from multiple value in meta separated by comma
- get_posts return only first result
- Why can my filter query SOME metadata but not other metadata?
- How to get meta key list efficiently?
- how to get wp_query posts only first letter of alphabet A?
- update_post_meta performance in a loop woocommerce
- update_post_meta performance in a loop woocommerce
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- I need query_posts() to order results first by a meta value and then by post ID
- get_posts query caching?
- Slow query when selecting with large meta query or post__in
- WP Meta Query at depth 2
- Ordering Posts by parent category, name ascending
- Use not custom fields in get_posts() meta_query?
- Mathematical operations on custom field values? (updated)
- How to get several fields from wp_query?
- Return a single custom post from multiple meta queries
- get_posts works but new wp_query doesn’t
- Why WP_Query in functions.php is not working when get_posts works?
- query by meta value then date and not empty meta value
- Query specific number of posts for each post type in specific order
- wordpress sorting using array merge by price in ascending order but price with 0 must be show last
- get_posts shows current post, not defined posts with args
- Query custom post types by meta field in a term from custom taxonomy
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Sort by multiple columns using get_posts