Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Empty search with taxonomy filter not working properly
This topic contains 16 replies, has 2 voices, and was last updated by ilariaroglieri 7 years, 6 months ago.
- AuthorPosts
- May 12, 2016 at 2:13 pm #8627
Hello,
I have the following problem:
I have a search bar with a dropdown menu for custom taxonomy.
I need the search bar to perform an empty search, so that if I filter one taxonomy term from the dropdown menu it returns the whole taxonomy archive to me.
Right now if i try to perform an empty search it seems to return the first results on all the products. I need it to return results only from the selected taxonomy.ps. Moreover now the dropdown is ignoring the max-height setting, I don’t know why…
May 13, 2016 at 9:06 am #8635Hi!
I think I know the reason why the max-height is ignored, it appears to be a yet unkonwn bug.
You can fix that issue by opening the wp-content\plugins\ajax-search-pro\includes\views\asp.shortcode.categories_terms.php file and going to line 322, which should be this:
<div class='categoryfilter'>
try changing that to:
<div class='categoryfilter asp_sett_scroll'>
It should fix the max height issue. If you need assistance, then feel free to provide temporary FTP details, and I will fix it for you.
Then, if I understand correctly, you want to display results matching from a taxonomy-term, but it can be from any given taxonomy. In that case, after selecting all the taxonomy terms you need on the Frontend search settings -> Taxonomy Terms panel and selected a drop-down layout, go to the Frontend Search Settings -> Advanced panel and change:
- Category/Taxonomy terms logic option to At least one selected terms should match – because you want to match at least one term, not neccessarily all of them.
- Logic between taxonomy groups option to OR – because you use different taxonomies, but at least one should match from any group
- (optional) Show posts/CPM with empty taxonomy terms? option to OFF – if you don’t want to display anything without terms, then turn this off.
Screenshot of the configuration: https://i.imgur.com/xrJioTO.png
I hope this helps.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 13, 2016 at 9:43 am #8636Thanks for your reply.
Unfortunately it is still not working as expected.
Let me explain better to you.
Let’s say I want to see all products inside “archi”.
So, I select archi from the taxonomy dropdown and press enter without inserting any character in the search.
I expect the search to show me all results under “archi” category, but what I see is all the catalog.
I attached you the screenshots of the settings to double check they are what you suggested.
In the secondo image attached you can see the results it shows after selecting the term from the dropdown and typing enter: as you can see it returns the first categories just as i was selecting all the terms.
The third screenshot shows you what i see if i press “mostra piĂą risultati” (show more results): i see exactly the whole catalog (as you can see also in the url, it’s not returning the filter but a search on everything).
The fourth screenshot show you what I would like to see: the taxonomy archive for “archi”. I obtain this precise result if i type “archi” in the search and select the first result (the taxonomy term “archi”).
So do you think it is possible to fix this?
Thanks
IlariaAttachments:
You must be logged in to view attached files.May 13, 2016 at 10:41 am #8641Hi!
Can you please provide temporary back-end and FTP access? I’m not sure what exactly is missing, I would like to check the configuration and then debug through the code if neccessary. It’s probably something we are missing.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 13, 2016 at 10:45 am #8642You cannot access this content.May 13, 2016 at 10:52 am #8643You cannot access this content.May 13, 2016 at 12:06 pm #8649Hi!
I think I found the main cause, and possible others as well.
1. The “select/deselect all” button you implemented on the top of the list is de-selecting everything, even the hidden elements of the form. It causes to not search within any post type, therefore it returns no product results.
I suggest adding a filter to the handler script to only select option, which are indeed terms, something like:$(“.asp_option_cat .option checkbox”)…
or:
$(“.option:not(.hiddend) checkbox”)…
This will make sure to select only visible checkboxes, nothing else.
2. I’m not sure if you need product tags/categories as results. If not, I suggest de-selecting them on General Options -> Sources 2 panel: https://i.imgur.com/aonDQTy.png
3. The results override is not activated, therefore the results on the default wordpress results page are not overwritten by Ajax Search Pro. Here you can read on how to enable that. After enabling, the same results should start appearing on the default search results page.
I hope it helps!
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 13, 2016 at 12:42 pm #8651Dear Ernest,
thanks for your reply.
I tried to to what you suggested and now it goes better, but still not working perfectly. In fact now it returns correct results below the input fields but when I select “show more results” it still redirects to the whole catalog. I activated the result override. Now I’ve also tried to disable the “select/deselect all” script I implemented but still there are these problems.
Please check again.
Ilariaps. By the way, may I suggest to implement a “select/deselect all” in future updates? I think is really something important missing in this very powerful plugin!
May 13, 2016 at 12:55 pm #8652Dear Ilaria,
Indeed, there was something with the override function not accepting the empty string for some reason. I’ve fixed it in the code directly, will include this in the next update of course, so it stays permanent. It should be working correctly now.
Yes, the select/deselect all feature is indeed very important, and it’s on the list for the upcoming updates – it had been requested many times. I’m working hard on the upcoming update, it’s going to be mostly around bugfixes and re-factoring old code parts + new API.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 13, 2016 at 12:58 pm #8653Well thanks Ernest, you’ve been very helpful!
When will the update with the bug fixed be available?
I hope very soon, my clients are going crazy about this…
Best,
IlariaMay 13, 2016 at 1:02 pm #8654I really hope I can finish it within a week (60-70 working hours I would say). The code is over 500 thousands of lines now, it takes lots of testing to make sure everything works after finishing it 🙂
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 16, 2016 at 1:48 pm #8681Dear Ernest,
sorry i have to bother you again but i hope this will be simpler.
I need the search results to be ordered by author name, not by title name. Author name is inserted as custom taxonomy and also in a custom field: i use it in custom field to make a pre_get_posts to set the query and order it by meta key, but of course search template is currently overridden by the plugin.
Any idea which setting can i use to configure ordering like this?
IlariaMay 17, 2016 at 10:18 am #8696Hi Ernest,
a quick update: if i disable “Override the default WordPress search results page” the order in the search page is correct (by custom field i.e. author name), except for empty field searches (which returns the whole catalog).
If I enable “Override the default WordPress search results page”, empty search performs correctly, but all searches (with empty or filled field) are ordered by title not by custom field.
Please give me some feedback.
IlariaMay 17, 2016 at 10:59 am #8700Hi!
Well, I can see two ways of resolving this:
1. Is to temper with the search query and add the ordering statement there. I do not recommend doing this, as it will be overwritten by the upcoming update.
2. Ordering the result objects by the new values using a filtering function. This is update proof, but harder to accomplish.
Can you disclose the code you have on the “pre_get_posts” filter? I might be able to put together a custom ordering function based on that, to order the result objects by the given meta field. However this ordering will only affect the actually visible result set (currently displayed page) results in the best case scenario – because it’s executed after the results are parsed and cut.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 17, 2016 at 11:32 am #8704Hi Ernest,
this is the code added in fucntions.php:add_action( 'pre_get_posts', 'order_by_cf' ); function order_by_cf( $query ) { if ( is_shop() && $query->is_main_query() || is_product_tag() && $query->is_main_query() || is_tax() && $query->is_main_query() || is_search() && $query->is_main_query() ) { $query->set('orderby', 'meta_value title'); $query->set('meta_key', 'author_name'); $query->set('order', 'ASC'); } }
as you can see orderby accepts two values (meta value for first, title as secondary).
Of course I would prefer to have this order set for the whole results.
Please let me know what’s the best thing to do.
Ilaria - AuthorPosts
You must be logged in to reply to this topic.