I tried the following code:
$posts = get_posts([
"post_type" => "CUSTOM_POST_TYPE",
"meta_query" => [
'relation' => 'AND',
[
'key' => 'longitude',
'value' => [-0.9895, 1.3125],
'compare' => 'BETWEEN',
"type" => "NUMERIC",
],
],
]);
When I remove "type" => "NUMERIC"
, I could reproduced your problem because the comparison is string based.
But when adding the type NUMERIC
, the MySQL request contains CAST(wp_postmeta.meta_value AS SIGNED) BETWEEN '-0.9895' AND '1.3125'
and the query returns the foreseen values.
Related Posts:
- WP User Query with search columns and meta query
- Combining Meta_Query key values for one array
- pre_get_posts and search query for admin
- Advanced Search by minimum/maximum values
- Searching by meta values showing inappropriate result
- WordPress, fetching users with an exact match in a string of comma separated values in user_meta
- Meta query: How do I return posts within a date period from a given month?
- meta_query issue with multiple numerics
- Custom Query Content Filtering
- Search by meta_query
- Exclude posts with certain meta data from search results
- Form for search pages by meta datas
- WP search in metadata post
- How can I implement a location based (zip code) search in WordPress?
- How to highlight search terms without plugin
- Template issues getting ajax search results
- Complex Search functionality. Advice needed
- How to use next_post_link and previous_post_link on single posts in search results
- Why is there a class=”screen-reader-text” on my search button?
- can’t limit search to only pages
- Include custom table into search results
- How to exclude post body from WP search
- ElasticPress Indexing multiple sites
- Search outside of the “loop”
- Replace URL with Site Title in Search Results
- Force WP to use a certain search template
- Do not allow to search certain words
- How to avoid the specific page while searching in WordPress without plugin?
- Best way to Integrate Google Search?
- Related Tags Concept
- How to add additional search terms (e.g. synonyms) to the search?
- Combine internal search with Google custom search?
- Search by keywords with boolean operators
- Redirect All Search Links Containing – to + on WordPress
- How to make wordpress Dynamic Search-Bar from Predesigned Static Html Search-Bar?
- How make a custom search on backend in WordPress without plugin?
- Change Search url slug for each site in a multisite network
- URL search link for ‘category__and’ instead of php query
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Search media by title and description – Frontend
- Is there a way to add a custom text + link above search results for different searches?
- How to change tab’s title in search results pages? [closed]
- Customise Excerpt start and end
- Template issues getting ajax search results
- How can I implement Search feature for Membership site?
- WordPress search with quotations returning to homepage
- Passing form inputs into multi-taxonomy query
- How to display search results in search.php
- Search WooCommerce Products in WordPress
- Search for two strings in WP search
- Strip HTML Tags From Search Results
- Should I create a parent page with no content? [closed]
- some one help . search not jump to search page
- Why should we use the name attribute with the value “s” in the creation of the search form?
- The Search FoRM Dilemma || The Search form Templating
- Search for anything in site
- How can I add search box in single.php?
- Independent search tool that returns exact match of a post title
- Connecting Google Site Search with WordPress Taxonomies/Categories/Tags
- Only display post content in search results
- meta post search
- search page not found? (search.php or searchpage.php)
- Media Library / Backend: How can I search for text in the ALT Text field?
- Rewrite wp function
- Search custom posts by meta key in admin
- How to fetch Email addres of an author via ID?
- How to Fix Form elements do not have associated labels in WordPress Search Form (without button)
- Search within the current page
- How to exclude specific post_type from default search?
- What are the available options for “Name” in WP search?
- Search issue on special Character
- Modify main search form to search user too
- Editing a Search Form
- Removing &submit=Search from search parameters?
- customize search result in wordpress
- Highlight search words in excerpt
- $_GET value is losing it’s space
- limit the number of searches
- Search For Custom Post Type and Custom Fields
- How can I prevent the Search Results Page from changing title?
- Problem with site’s search results “Read More” link?
- Searching on my blog is not working
- “Modular/reusable” content and search results
- Make the title and […] clickable in result search
- Add Search Form to Dropdown menu
- Search doesn’t work with ‘relation’ => ‘OR’
- Add meta tag to search results
- Searchform for searching specific categories
- Selectbox and Searchform and Custom Search Page
- Hightlight search-terms with functions does remove or disable other filters?
- wp_redirect and search engine bots
- SQL: Search query to get attachments only of those parents which are published
- Change the text “search result for” on search result page
- Search redirects to index
- Want to creat a search for my wordpress theme [closed]
- How to remove search bar from the blog post
- Return 404 for /search/ queries – For Genesis
- Deprecating WordPress URL from Google, promoting custom domain [closed]
- Search with multiple selects that include tags
- Search results from a specific database table