Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Settings
- This topic has 31 replies, 2 voices, and was last updated 7 years, 1 month ago by
kondor.
-
AuthorPosts
-
April 1, 2019 at 2:01 pm #21941
Ernest Marcinko
KeymasterHi,
1) That is intentional, as each tag is considered as a single word, it will not work with multiple words unfortunately.
2) This can be very problematic. Currently in WordPress, there is only one way to get the categories in hierarchical order, and that is, when the all the categories are requested.
A few weeks ago there was a similar request, and this custom code was the closest we could work out together. You should try that, however there is no guarantee it works, and there is no other usable solution either. We even tried to iject the one from the WordPress core, but that does not work without getting all the terms.April 2, 2019 at 11:40 am #21956kondor
ParticipantHi Ernest
ok, i get your point.
I implemented the code you suggested for categories hierarchy – seems to work ok.
1) i found why i am getting results that shouldn’t appear – it is related to a custom term meta that is called ‘cat_seo_text’ which include in its text the search phrase and that is why it showed up even though this category did not have a tag.
how can i exclude the term ‘cat_seo_text’ from search?
2) due to comma and multiple keywords issues with additional tags (your plugin built in tags) i took your advice about changing custom fields for tags into simple text field.
only problem now is that for each tag that i add – it adds +1 to the custom field name :
i set up a tab containing the repeater fields for tags and it is called “product_search_help_tags”
each repeater field is called “product_tag_field” – but when i search for ” drag here custom fields you want to use!”, the repeater fields is in array so it adds up 0,1,2,3 (+1 to each new repeater/tag that i add).this forces me to keep track each time of the post with biggest amount of tags and add it…
pls see attached screenshot.
is there a way to globally search EACH product_tag_field without the need of rechecking how many tags the website owner added?
THANK YOU VERY MUCH !!! 🙂
April 2, 2019 at 2:33 pm #21958Ernest Marcinko
KeymasterHi,
I think both might be possible, but only with major modifications to the code, which means, that an update will overwrite this functionality.
If you want, I can try arranging these modifications, just wanted you to know, that it won’t be compatible with future versions.
April 2, 2019 at 6:12 pm #21964kondor
ParticipantHI Ernest,
which one requires major mods? 1 or 2?
in case you will point me out to these mods – wont i be able to re apply them after update?
April 3, 2019 at 10:40 am #21975Ernest Marcinko
KeymasterHi,
The first one is a bit simpler, it might affect only one line, the second one is more complicated, I’m am not entirely sure. If there are any changes within those core files, then it might not be possible to replicate them after update.
April 3, 2019 at 12:03 pm #21981kondor
ParticipantHi Ernest,
ok – so lets handle only first issue only (the 2nd issue i will follow up and add it manually)
thanks 🙂
April 3, 2019 at 1:33 pm #21986Ernest Marcinko
KeymasterOkay, so for the first modification, open up the wp-content/plugins/ajax-search-pro/includes/classes/search/class-asp-search-terms.php file, and look for these lines (around line 110):
if ( $args['taxonomy_terms_search_term_meta'] == 1 ) { if ( $termmeta_join == '' ) $termmeta_join = " LEFT JOIN $wpdb->termmeta tm ON tm.term_id = $wpdb->terms.term_id"; if ( $kw_logic == 'or' || $kw_logic == 'and' || $is_exact ) { $parts[] = "( " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'$wcl" . $word . "$wcr'$suf_like )"; } else { $parts[] = " (" . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'% " . $word . " %'$suf_like OR " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'" . $word . " %'$suf_like OR " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'% " . $word . "'$suf_like OR " . $pre_field . "tm.meta_value" . $suf_field . " = '" . $word . "')"; } }..and replace them with these:
if ( $args['taxonomy_terms_search_term_meta'] == 1 ) { if ( $termmeta_join == '' ) $termmeta_join = " LEFT JOIN $wpdb->termmeta tm ON tm.term_id = $wpdb->terms.term_id"; if ( $kw_logic == 'or' || $kw_logic == 'and' || $is_exact ) { $parts[] = "(tm.meta_key NOT LIKE 'cat_seo_text' AND " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'$wcl" . $word . "$wcr'$suf_like )"; } else { $parts[] = "( tm.meta_key NOT LIKE 'cat_seo_text' AND (" . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'% " . $word . " %'$suf_like OR " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'" . $word . " %'$suf_like OR " . $pre_field . "tm.meta_value" . $suf_field . " LIKE $pre_like'% " . $word . "'$suf_like OR " . $pre_field . "tm.meta_value" . $suf_field . " = '" . $word . "') )"; } }Let me know if you can’t change this, and I will do it via FTP.
April 6, 2019 at 10:13 am #22056kondor
Participanthi ernest,
thanks, it works great.
i found out that some other fields are being searched (such as “thumbnail_id”) and if i type a phrase that is included in the id of the thumbnail, it is returned too… which is not ok.
i tried your code by changing it to: …….tm.meta_key NOT LIKE (‘cat_seo_text’,’thumbnail_id’) AND ” . $pre_fiel……… – but after that i get 0 results…
is my query modification wrong?
i also have the following code in functions (so it will return the correct image for result:
add_filter( “asp_results”, “asp_acf_cf_image”, 1, 1 );function asp_acf_cf_image( $results ) {
// Change this to the ACF custom field name
$image_field = ‘thumbnail_id’;foreach ( $results as $k => &$r ) {
if ( empty($r->image) && $r->content_type == ‘term’ ) {
$imgID = get_field($image_field, $r->taxonomy . ‘_’.$r->id);
$img = wp_get_attachment_url( $imgID );
// $img = $imgArray[‘url’];
if ( !empty($img) )
$r->image = str_replace(“‘”, “%27”, $img);
}
}
return $results;
}but even after removing it from functions, still 0 results…
any idea what is wrong here / or maybe how can i safely exclude other terms meta fields that might return wrong results (same as ‘cat_seo_text’ you excluded)?
thanks!
April 8, 2019 at 8:20 am #22066Ernest Marcinko
KeymasterHi,
Yes, that query modification is not correct, but you can easily fix it. Instead of this:
tm.meta_key NOT LIKE ('cat_seo_text','thumbnail_id') ANDuse the NOT IN operator like so:
tm.meta_key NOT IN ('cat_seo_text','thumbnail_id') AND..and that should do the trick.
April 12, 2019 at 2:09 pm #22137kondor
ParticipantHi Ernest
ok, i finally decided to change the query into searching only in specific custom field instead of excluding all the others… works great!
1) is it possible to count amount of products in product category result and display it? (for example: result = product category “tables” which has 40 products in it) – so can i get the result to show “Tables (40 items in total)” as a result?
2) i would like to rate your plugin and support since it is truly great, so i would appreciate if you can paste a link where i can rate it 🙂
thanks!
April 12, 2019 at 2:32 pm #22138Ernest Marcinko
KeymasterHi,
1. Well, there is this option. It will display the number of associated items after the term. It is not that fancy, but it should work.
2. Thank you for your kind words. You can rate the plugin If you like the plugin, feel free to rate it on your codecanyon downloads page 🙂
April 17, 2019 at 10:50 am #22197kondor
ParticipantDone! million thanks my friend 🙂
** I gave a review too 🙂
April 17, 2019 at 4:13 pm #22218kondor
Participantjust another small question:
vertical results have a small 20px (approx.) margin from search field and it is controlled by js.
can you point me out to the correct file? i want to reduce that margin to 0 (search results start right after the search field)
thanks
April 18, 2019 at 8:28 am #22230Ernest Marcinko
KeymasterHi!
There is actually an option for that here: https://i.imgur.com/723B55d.png
Try changing that to 0, or even negative values, if it is still not close to the field.April 18, 2019 at 8:38 am #22232kondor
ParticipantYou cannot access this content.
-
AuthorPosts
- The topic ‘Settings’ is closed to new replies.