• Resolved sigrundish

    (@sigrundish)


    Hi,
    The search doesn’t work on my page for custom taxonomies.

    For example, if I search for the brand Nike, I can see the correct amount of results in the parentheses behind Nike in the dropdown option that appears, then when I click on the option the URL changes to: …/shop/?brand=nike

    But the page shows all of my products. The query parameter doesn’t work.

    I’m using BeRocket Ajax Filters. When I filter by brand the URL is: …/shop/filters/brand/nike/

    How do I fix it? So the search works for custom taxonomies? It works fine for product categories.

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    Can you please give me a link to your site search page so I can test it by myself?

    Regards

    Thread Starter sigrundish

    (@sigrundish)

    Yes we haven’t launched yet so our site it is in coming soon mode but I can turn it off on our staging environment so you can test. There are only few test products but you can test with for example the brand “Saks pots” or “Ganni”.

    https://visteyristg.wpengine.com/

    Plugin Author ILLID

    (@mihail-barinov)

    Thanks. So I can search for some brands there but it looks like search results pages are disabled. Can you please enable it?

    Regards

    Thread Starter sigrundish

    (@sigrundish)

    We have opened up for our live site so you can test there: https://visteyri.is

    What do you mean by the search results pages are disabled? Where do I enable it?

    Plugin Author ILLID

    (@mihail-barinov)

    Please forget about the search page – I just misunderstood you the first time.

    So if you open the site admin page and go to products -> YOUR CUSTOM TAXONOMY NAME page, choose one of taxonomies and click View – what URL of the page do you see where this taxonomy will be opened?

    Thread Starter sigrundish

    (@sigrundish)

    There is no option to view it…
    See screenshot: https://jmp.sh/l1ZIB29b

    But the taxanomy name is merki and the slug for one of the “merki” (e. brand) is: ganni.

    If I edit the brand the url is: https://visteyri.is/wp-admin/term.php?taxonomy=merki&tag_ID=815&post_type=product&wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dmerki%26post_type%3Dproduct%26s%3Dganni

    If I open all of the products of that brand within the admin console the url is: https://visteyri.is/wp-admin/edit.php?merki=ganni&post_type=product

    Plugin Author ILLID

    (@mihail-barinov)

    In this case please tell me – how do you create these brands? Are you using any plugin or maybe custom code for this?

    Thread Starter sigrundish

    (@sigrundish)

    Hi,

    We used custom code, like this:

      $brand_labels = [
        "name" => _x("Merki", "taxonomy general name"),
        "singular_name" => _x("Merki", "taxonomy singular name"),
        "search_items" => __("Merki"),
        "all_items" => __("Merki"),
        "parent_item" => __("Parent Merki"),
        "parent_item_colon" => __("Parent Merki:"),
        "edit_item" => __("Edit Merki"),
        "update_item" => __("Update Merki"),
        "add_new_item" => __("Add New Merki"),
        "new_item_name" => __("New Merki Name"),
        "menu_name" => __("Merki"),
      ];
    
      // Now register the non-hierarchical taxonomy like tag
      register_taxonomy("merki", "product", [
        "hierarchical" => true,
        "labels" => $brand_labels,
        "show_ui" => true,
        "public" => false,
        "publicly_queryable" => false,
        "show_in_rest" => true,
        "show_admin_column" => false,
        "query_var" => true,
        "rewrite" => ["slug" => "merki"],
      ]);
    }

    Do you notice anything missing that might be the cause?

    Plugin Author ILLID

    (@mihail-barinov)

    I see that these brands are not publicly available. Did you do it on purpose or was it just a mistake??

    You can change the line

     "public" => false,

    to

     "public" => true,

    After this you must see its URL inside the admin page and perhaps this will fix an issue with links inside search results.

    Regards

    Thread Starter sigrundish

    (@sigrundish)

    It must have been a mistake, this code was added by someone else than myself so I’m not sure why it was set to false.

    It did not work to change “public” to true but after I changed “publicly_queryable” to true as well the view option appeared and it links to:

    https://visteyri.is/merki/ganni/

    However, the URL doesn’t work. The page shows all products, not filtered by the “merki” (e. brand) Ganni.

    Plugin Author ILLID

    (@mihail-barinov)

    So it is a link that I see from the admin area for your brand taxonomy. Is that correct? If so then it looks like the issue is not in the searching plugin but more common and related to your site and custom taxonomy that is created for it.

    I think can can set to true both publicly_queryable and public parameters.

    Also please try to remove

     "rewrite" => ["slug" => "merki"],

    After this go to the WP admin dashboard -> Settings -> Permalinks page and click Save Changes button to reload permalinks structure.

    Thread Starter sigrundish

    (@sigrundish)

    I managed to fix it.

    We also have the plugin Ajax Product Filters by BeRocket.

    I changed the premalink structure so that it matches the pattern for the filters, then the search works when you click on custom taxonomy.

    Thread Starter sigrundish

    (@sigrundish)

    Thank you so much for the help!

    Plugin Author ILLID

    (@mihail-barinov)

    Glad that your problem was solved successfully.

    Thread Starter sigrundish

    (@sigrundish)

    Hi again,

    We just realised it broke our blog page. Now the “filters” parameter is in front of the url for blog posts as well.

    Is there a way to adjust the URLs of custom taxonomies in the search so the results links to …/filters/custom-taxamony/value (such as /filters/brand/nike) but make sure the filters parameter is not added in front of our blog posts?

    You can test on our site https://visteyri.is

    If you click on the “blog” link in the footer and select a blog post you can see that the /filters/ is added in front of the URL causing us not to be able to access the blog posts.

    But if we take the settings out of our premalink structure the search doesn’t work. Then the brand nike links to https://visteyri.is/merki/nike which doesn’t work, instead of https://visteyri.is/filters/merki/nike which works (merki means brand in Icelandic)

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Query parameter added after searching not working’ is closed to new replies.