Problem was that I had a plugin installed that deals with the searches, it’s called Better Search.
function query_1($query){
$query .= ",wp_postmeta.meta_value as total_saless ";
return $query;
}
add_filter( 'bsearch_posts_match_field', 'query_1' );
function query_2($query){
$query .= "AND wp_postmeta.meta_key='total_sales' ";
return $query;
}
add_filter( 'bsearch_posts_where', 'query_2' );
function query_3($query){
$query = " CAST(total_saless AS INTEGER) > 99999 DESC, score DESC ";
return $query;
}
add_filter( 'bsearch_posts_orderby', 'query_3' );
All I had to do was to hook into it.
Related Posts:
- Search custom post type by meta data
- what are the numbers between curly brackets in search query
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- How to display liked posts of current user in wordpress?
- Filter query posts by the count of metas for a meta key
- search through post-type attachments titles
- Save default value for empty or missing post meta
- Grouping related postmeta data via SQL query
- mySQL query. ORDER BY meta_key
- Remove posts from query for events whose start date has passed
- Change searched term
- Query metas (and not : query posts by metas)
- Search query -> Show all pages except certain template
- Temporarily storing main search result
- Query based on title, with ‘compare’ => ‘IN’
- is_search called incorreclty
- Issue with using add_rewrite_rule() for post querying custom fields
- Attempt to improve WP search, can someone check my SQL query?
- Searching With Apostrophe
- Query posts according to specific post meta values
- How to reset usual $query on search page to push custom $wpdb query there?
- Order by meta value pro first then meta value free in my search function
- How to query two meta fields and display results between them
- Ideas how to search & replace post_content when string contains a newline?
- How to insert Collate into WordPress search query?
- Slow Search Queries – How to exclude pages, media, excerpt, authors, private posts?
- How to interfere to default search to make it search in custom fields?
- How to manage a particular “order by” for get_search_query()?
- get_post_meta with WP_query
- Declaring a var, placing it in a query and using the output of the query?
- Combining two meta_values within one row with query
- WordPress search in modified post title
- Filter orders by modify date
- How to add url parameter to every search query in SearchWp?
- Add rewrite rule for archive search
- Restrict WordPress search to a single ACF field
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- Modify behaviour of “s” parameter in wp_query
- searching by keywords in post’s metas or pagination links problem
- Pagination adds search query (again)
- Speed up search query that searches in post meta?
- How to make MySQL search queries with quotes
- Use $wpdb->get_results with filter based on array
- $query->set( ‘post_type’, ‘post’ ); not working
- What is the best way to query posts based on live data?
- Custom MySQL Query for Post and Post Meta
- search.php is not generating the right results
- Run search query again without pagination gives no results?
- is_search called incorrectly
- How to display SQL query that ran in query?
- Advanced search form with filters for custom taxonomies and custom fields
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- order by numeric value for meta value
- How to make search include data from wp_postmeta?
- How to get comments by post ID?
- Differences between wpdb->get_results() and wpdb->query()
- Is there a way of increasing the speed of this query?
- Get all image from single page using this query
- How can I query all users who registered today?
- Get Terms by IDs with IDs order
- WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
- Reversing the order of posts AFTER the query is performed
- simple sql query on wp_postmeta very slow
- Ascending & descending posts on same page with IF statement
- How do I find users by password?
- Search query alteration not working for meta values
- Prevent executing query for wp_global_styles
- Search results stuck on page 1
- How to use a dynamic term id for the query block
- Querying Posts from ACF Repeater Subfield Select Value
- How to figure out correct wp_options to have autoload=’yes’
- Advanced Search – Is this possible?
- Meta Query compare with LIKE pulls similar post types: 55 and 155, and 1,155
- How to show sticky posts on all pages of the pagination, not just the first page?
- Extend search query to search meta keys values based on search string
- Searching for a custom meta from user.php in the admin
- Search for meta_query does not return any result if combined with title
- How to get posts that have certain meta key value and order based on another meta key’s value
- Why does $_GET return values but get_query_var does not?
- Sort users in admin screen by meta value whether it exists or not
- is it possible to get a list of URLs from post_content directly in a mysql query via phpadmin?
- Modify WordPress Search
- Can I make a Heading block above a query loop block disappear when that query loop has no results?
- Get URL parameters with rewrite rules
- Elementor – Sort by name
- Rewrite URL custom search query
- pre get posts not working with Tribe Events
- How do you create a query to hide all posts with a certain meta key, unless current user is the author of that post, without custom SQL?
- Search posts by meta key in admin and front
- Custom API how to return int field
- import/view table from external site
- Problem in MySql query on WordPress [closed]
- Can I filter existing search query using pre_get_posts for post_mime_type?
- 404 with google ads query params
- Add specific postmeta to search query
- “Page Not Found” with multiple last pages of query
- prepare select of array
- How to allow searching a custom meta key in admin list table?