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?
- order by numeric value for meta value
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Custom query_var causes displaying posts archive on front page
- Why does get_the_time(‘F j’) return November 30 for all posts?
- WPDB Multiple site’s posts and get featured images
- Search everything (posts, pages, tags, cpt, meta)
- How to limit search to first letter of title?
- is_archive() doesn’t work on public query var archive pages?
- Possible to get posts from multiple meta keys/values in a single query?
- Difference between fragment caching and wp_cache
- How to display all posts with today’s same month and day only?
- Select User by Joining Multiple Meta Value Results
- How do I search inside specific taxonomies in WordPress
- Show featured image as background image from postQuery
- Using $wpdb->update but confused on the WHERE in and SET
- sort search results by custom fields using dropdown
- You have an error in your SQL syntax – Help with query
- Make one query for adding entries to database
- add_query_arg() and empty variables inside
- Query Strings and Woocommerce
- Style Post Differently In Query
- WordPress post type “event” query string fix?
- Get Meta Key Value While Saving Post
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Function to delete a post, it’s children and it’s grand children (half way there already)
- Dynamically adjust single-posttype.php query, based on current taxonomies
- Use mysql_query instead of $wpdb query
- Change the destination of the URLs in post.php
- Page with custom template make get request to a custom route – Pseudo code
- get_users with array as meta_value
- How to exclude posts for current user
- exclude pingbacks from wordpress SQL query
- wp_posts query slowing down my website
- Advanced Custom Fields – Relationship post foreach query
- How do I query for posts by custom meta and those that have been stickied?
- Select min/max meta from query
- WordPress query unique post meta – finding all of one value without duplicates for a drop down
- Exclude in get_pages() based on meta field
- How do I set the Stewart Search Template to return only published posts in the result
- Query Post interferes with Pagination
- Exclude Posts from a Widget
- New custom post type entries are not sorted correctly in admin using pre_get_posts
- Query String for the WP_QUERY parameters
- Sorting of coupons in the right way
- excludeCat function reverses order of blog posts
- Advanced search form with filters for custom taxonomies and custom fields
- Form Data Causes “Page Not Found”
- Where can I find the SQL to get the most used information by wordpress database?
- AJAX loading with custom parameters
- How do I troubleshoot Maximum execution time of 60 seconds exceeded in updating a Media File?
- update $wpdb one query
- How to use a dynamic term id for the query block