Skip Navigation

[Gelöst] Same search filter for different post types (sharing taxonomies)

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

Customize the taxonomy archive pages.

Solution:

You can setup Toolset WordPress Archive for taxonomy "super-category", and add custom search form in it, see our document.

Relevant Documentation:

https://toolset.com/course-lesson/creating-a-custom-archive-page/

This support ticket is created vor 3 Jahre, 3 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 13 Antworten, has 2 Stimmen.

Last updated by Ido Angel vor 3 Jahre, 3 Monate.

Assisted by: Luo Yang.

Author
Artikel
#1896011

Hey,

I have 3 posts types which are sharing the same taxonomies . Post types are "products", "recipes" and "magazine-items", and taxonomies are "product-brands" and "super-category".

I want to create an archive for "super-category" which will include in it all 3 post types. What I did is:

1. created the archive in elementor
2. created 3 views, one for each post type, with filter of "super-category" the same as the current archive.

so far so good.

now, I want to have 1 parametric search to filter results by "products-brand", but even though I enter the filter in all 3 views, it doesn't really work. It filters just 1 view.

SO...

I tried this code:

jQuery(".tax-super-category .products-filter-home select[name='wpv-product-brand']").on("change", function(e) {
    var chosenCat = jQuery(this).find("option:selected").val();
    jQuery(".tax-super-category .super-recipe select[name='wpv-product-brand']").val(chosenCat).trigger("change");
    jQuery(".tax-super-category .super-mag select[name='wpv-product-brand']").val(chosenCat).trigger("change");
  });

It works, but quite unstable. You can see here:

hidden link

try filtering by "morphy richards" - great, the results change accordingly. But if you reload the initial page and then try filtering by "ninja" - the products which belong to "morphy richards" are still appearing even though they don't belong to "ninja".

I'm sure there's a better way of getting about this, but what is it?

Thanks!

Ido

#1896779
521.JPG

Hello,

I have tried the URL you mentioned above, but get 521 error, see my screenshot: 521.JPG

And I have enabled the private message box, you can also provide your test site credentials in it. thanks

#1896911

I can see the problem in your website, and the problem is abnormal, please check these:
1) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2021, deactivate all custom PHP/JS code snippets, and test again

2) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

3) If the problem still persists, please provide database dump file(ZIP file) of your website, you can put the package files in your own google drive disk, share the link only, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1898137

The URL you mentioned above is archive page of taxonomy "super-category", in order to customize it, you need to setup Toolset WordPress Archive for taxonomy "super-category", and add custom search form in it, see our document:
https://toolset.com/course-lesson/creating-a-custom-archive-page/

Please let me know if you need assistance to setup the WordPress Archive

#1898221

I don’t understand. I already did that. It’s there.

#1898237

Let me elaborate the problem again:
1) The URL you mentioned above:
hidden link

It is archive page of term אקלים-קיץ taxonomy "super-category"

But you are using some normal post view in above archive page, it will conduct unexpected result.

2) So you will need to follow our document to customize it:
https://toolset.com/course-lesson/creating-a-custom-archive-page/

And I have setup a demo in your website:
1) WordPress Archive here:
hidden link

2) Test it in front-end:
hidden link

I can see it works fine.

And since you are using Elementor plugin, you can follow our document to use Elementor Library block within Toolset WordPress Archive
https://toolset.com/course-lesson/using-toolset-with-elementor-page-builder/

#1898245

It also works in my view, which is a regular view with filter "super category is the same as the current archive" - if I only use "products" there. I used a normal view because I need a different layout for each post type - products, magazine items, and recipes. Using the post type conditional in one view wouldn't work too, because the results have a different display + can't appear mixed.

#1898251

Also, for some reason, I don't get any html except for the product names:

hidden link

#1900707

I think there is a misunderstanding.

The WordPress archive page is for outputting posts belong to current archive page, you can use Toolset WordPress Archive to customize(Style/format) the results, this is clearly described in the document I mentioned above:
https://toolset.com/glossary/archive/

In you case, since you want to do something differently in the archive page (different layout for each post type - products, magazine items, and recipes), I suggest you create another WordPress page, put those normal post views into that page, it should works as you expected.

#1900799

But Luo that's what I did... almost. I need an archive page for each term in the taxonomy "super category". I don't want to create a different page for each term, so I followed your advise and created a regular page:

hidden link

and in the view section I filtered the "super category" by url param, hence when I go to:

hidden link

I'm getting the right results.

BUT STILL, the default filtering by "brand" doesn't work (e.g. when I filter the products there by brand, it doesn't effect recipes or magazines and they stay the same). So I added my code there:

jQuery(".tax-super-category .products-filter-home select[name='wpv-product-brand']").on("change", function(e) {
    var chosenCat = jQuery(this).find("option:selected").val();
    jQuery(".tax-super-category .super-recipe select[name='wpv-product-brand']").val(chosenCat).trigger("change");
    jQuery(".tax-super-category .super-mag select[name='wpv-product-brand']").val(chosenCat).trigger("change");
  });

...and we're back to square 1. the behaviour is the same as in the initial post here, meaning:

try filtering by "morphy richards" - great, the results change accordingly. But if you reload the initial page and then try filtering by "ninja" - the products which belong to "morphy richards" are still appearing even though they don't belong to "ninja".

#1900809

Since you are using one search form to filter two view's result, I suggest you disable the AJAX search feature, add the submit button into search form, enable option "Full page refresh when visitors click on the search button", and test again

#1900827

Thanks, but isn't there a way to make this work with ajax? Page refreshed scare customers away + everywhere on the site (and it's a big site) we have ajax which works fine.

#1900887

No, there isn't such a built-in feature, one AJAX search form can filter only one search result, you can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

#1900889

Ok Luo, thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.