I am trying to: Example - when a visitor searches "stress" it should return all service listings containing the word "stress".
Link to a page where the issue can be seen: hidden link
I expected to see: Service listings containing the word "stress" only.
Instead, I got: Unrelated results containing the word "distress"
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Well - I would like to know here how you configured the text search? using View or it's a normal WordPress search?
Hi there! I'm using Toolset views. Do you know how I can sort this?
Also I would like to learn how visitors can filter results - is there guidance to do help me set this up please?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Can you please share the screenshot of your edit view page?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
The whole edit view page that will help 🙂
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Thank you.
Well - to have a exact match of a search keyword, you need to add the following code to your current theme's functions.php file
add_filter( 'posts_search', 'func_search_by_exact_title', 1000, 2 );
function func_search_by_exact_title( $search, $wp_query ){
global $wpdb;
global $WP_Views;
if($WP_Views->current_view == 999){
if ( empty( $search ) )
return $search; // skip processing - no search term in query
$q = $wp_query->query_vars;
$search = '';
foreach ( (array) $q['search_terms'] as $term ) {
$term = esc_sql( like_escape( $term ) );
$search = " AND ($wpdb->posts.post_title REGEXP '[[:<:]]{$term}[[:>:]]')";
}
}
return $search;
} // Only return an exact match to the input string - not partial matches
Where:
- Replace 999 with your original view ID
Is the original view ID the same as the slug? Or is it something different?
Thanks,
Cat
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
When you will visit Toolset => Views
It will display all views with ID column in tabular format, you need to replace the respective view ID not the slug.