Empty search with taxonomy filter not working properly

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

 
Participant
5 years, 8 months ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #8627

    Participant

    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…

    #8635

    Hi!

    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 :)


    #8636

    Participant

    Thanks 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
    Ilaria

    Attachments:
    You must be logged in to view attached files.
    #8641

    Hi!

    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 :)


    #8642

    Participant
    You cannot access this content.
    #8643

    Participant
    You cannot access this content.
    #8649

    Hi!

    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 :)


    #8651

    Participant

    Dear 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.
    Ilaria

    ps. 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!

    #8652

    Dear 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 :)


    #8653

    Participant

    Well 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,
    Ilaria

    #8654

    I 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 :)


    #8681

    Participant

    Dear 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?
    Ilaria

    #8696

    Participant

    Hi 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.
    Ilaria

    #8700

    Hi!

    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 :)


    #8704

    Participant

    Hi 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() &amp;&amp; $query-&gt;is_main_query() || is_product_tag() &amp;&amp; $query-&gt;is_main_query() || is_tax() &amp;&amp; $query-&gt;is_main_query() || is_search() &amp;&amp; $query-&gt;is_main_query() ) {
     
    	$query-&gt;set('orderby', 'meta_value title');  
            $query-&gt;set('meta_key', 'author_name');  
            $query-&gt;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

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.