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
- simple sql query on wp_postmeta very slow
- wordpress query – orderby child post date
- How do I search events between two set dates inside WP?
- Compare two numeric custom fields
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- Fulltext search in posts sorted by relevancy
- How to create a WP_Query to search the Title or Tag?
- WordPress Search Filter Only for Page with Child of Child of Child of Child of Child
- WordPress creating excessive joins on meta_query with search
- If No Search Results, Show Posts from Alternate Search Query
- Search query – exact post title match
- How to remove duplicate query on page load or make them cacheable
- Pull post meta with post_query?
- Huge amount of queries on my site
- WordPress Orderby Numeric Value Not Working
- Searching by meta values showing inappropriate result
- How do I use get_query_var() within plguin code
- How to display related posts by same publish date?
- Get post according to current taxonomy
- filtering custom post types via meta data drop down
- Alter query with posts_clauses to retrieve NULL values last
- WordPress Query orderby title with UTF8 string in title
- get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)
- Display posts between two particular dates
- Order posts by date, but also give priority for a specific term
- $post->ID not working in combination with a custom query
- Combine “Exclude” Query in functions.php
- Wrap/close ‘query’ for a first-letter ordered listing of posts
- wpdb query with dynamic column name?
- How do you display the number of a post in a query?
- How can I get the name of term post meta value which equals term id
- WP_Query meta compare must include ALL array values
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- get products by custom date variable
- Compare User meta_value with Product meta_value
- How to delete all images from code in all post_content
- How to sort by two meta keys in admin area?
- wp query multiple values > display a specific value first
- PHP Fatal error: Uncaught Error: Call to a member function insert() on null
- Nested select statements not working
- Add to search posts query array with post IDS which will appear first
- OR condition not working
- Add Hook for clearing transient when post is added
- Show links to child pages on both parent AND child pages
- Modify Global Posts Plugin
- SQL: Search query to get attachments only of those parents which are published
- How to reference same column name but different table in custom db query
- Retrieving custom field array value through db query
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- AJAX loading with custom parameters