Skip Navigation

[Resolved] Filter for taxonomies

This thread is resolved. Here is a description of the problem and solution.

Problem:

Setup many-to-many relationship between terms of same custom taxonomy "Topic".

Solution:

There isn't such kind of feature within Toolset or WordPress, you might consider other workaround, for example:

https://toolset.com/forums/topic/filter-for-taxonomies/#post-2094317

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-taxonomy-archive

This support ticket is created 3 years, 11 months ago. 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.

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 10 replies, has 2 voices.

Last updated by adrian-mihaiN 3 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2093633

Tell us what you are trying to do?

I am building a course directory and I have 1 CPT and multiple taxonomies: Platform, Institution(optional), Category, Topic.

The category has a main category and sub-category.

On all of them, I also want to also have a view of the Free filter. So site/topic/topic-name/free.

Is my approach correct with 1 CPT and just have taxonomies for the rest?

What is the best way to automatically generate the filtered Free archive pages? I also want them to have a custom layout and SEO meta using RankMath.

The "free" field is part of the Course CPT fields.

Another difficulty I run into is the fact that each Topic has related Topics and I would like to include the list of related topic links in the taxonomy archive page.

Topics also have a relationship to Category.

Thank you.

Is there any documentation that you are following?

No.

Is there a similar example that we can see?

No.

#2093731

If you check the footer of this site (where they show the site structure), it's the closest to what I want to do hidden link

They have subjects on 2 levels that are my categories and sub-categories but I also have topics that provide a narrower grouping, almost like a search result.

#2094015
tax-filter.JPG

Hello,

Q1) What is the best way to automatically generate the filtered Free archive pages?

You can follow our document to setup Toolset WordPress Archive, and add custom search form in it:
https://toolset.com/course-lesson/creating-a-custom-archive-page/
https://toolset.com/course-lesson/creating-a-custom-archive-page/#add-a-custom-search-to-an-archive

Q2) Another difficulty I run into is the fact that each Topic has related Topics and I would like to include the list of related topic links in the taxonomy archive page.

It needs nested view, for example:
1) Dashboard-> Toolset-> Settings-> General
in section "Editing experience", enable option: Show both the legacy and Blocks interface and let me choose which to use for each item I build
So you can setup the views with classic editor

2) Dashboard-> Toolset-> Views, create two views:

a) Parent taxonomy view:
- Query taxonomy categories terms
- Filter by:
Taxonomy is set by the page where this View is inserted
See my screenshot tax-filter.JPG
- In view's loop, display below child post view shortcode

b)Child post view
- Query Topic posts
- Filter by:
Select posts with taxonomy:
Categories set by the parent Taxonomy View
- In view's loop, display Topic post information

#2094087

Hi,

A quick follow up please:

1. I should have been more clear. I know how to create filtered archives.

My question is how do I generate an extra taxonomy "/Free" that gets automatically added to an existing taxonomy. Maybe my wording is not the best as it's just a filter.

An example would be site.com/courses/taxonomy and I want to also have site.com/courses/taxonomy/free generated automatically and will use a filtered view.

2. Should I have Category and Topics set as different CPT's with a one to many relationship?

Can I use the block editor for a much better design experience for the archive page and just insert the Topic view shortcode on it?

3. Given my desired organization: Platform, Institution(optional), Category, Topic + one that I forgot I need Instructors which ones need to be CPT and which Taxonomy for Course? A course must have Category but optional platform, institution, topic or instructor but will often have several of those.

Thank you.

#2094173

q1) how do I generate an extra taxonomy "/Free" that gets automatically added to an existing taxonomy

No, there isn't such kind of built-in feature within Toolset plugins, you need to add the terms "free" manually.

Q2) Should I have Category and Topics set as different CPT's with a one to many relationship?
I assume the "Topics" is a custom taxonomy, for the original question of this thread:

Another difficulty I run into is the fact that each Topic has related Topics and I would like to include the list of related topic links in the taxonomy archive page.

How do you setup the relationship between Topic terms?
If you want to display the child Topic terms(subcategories), it needs just one taxonomy view:
- Query terms of "Topic"
- Filter by:
Select taxonomy terms whose parent is the current taxonomy archive.
- In view's loop display the term information

Q3) Can I use the block editor for a much better design experience for the archive page and just insert the Topic view shortcode on it?
Blocks editor does not support Taxonomy view yet, you need to use classic editor to setup the taxonomy view.

Q4) Given my desired organization...
That depends on yourself, if you want to manage those "Institution(optional), Category, Topic" easily just like WP built-in taxonomy "category", then setup them as custom taxonomy

#2094179

Super helpful, thanks.

One thing left from both tickets that I am not yet sure how to do.

Topics are not categories, think of them as WordPress tags.

Each individual topic will have related topics.

1. How do I structure the field or relationship inside the Topic CPT

2. How do I display them

My guess is to use a repeater field but I want to make sure I am on the right path.

The problem doing it this way is that it's not a 2-way relationship.

#2094219

I assume we are talking about a Flat taxonomy "Topics", just like WordPress built-in taxonomy "Tags", it is not possible to setup relationships between "Topics" terms, this is how Flat taxonomy works.

If you just need the one-to-many relationship between "Topics" terms, you can try to setup "Topics" as a Hierarchical taxonomy, see our document:
https://toolset.com/course-lesson/creating-a-custom-taxonomy/#using-hierarchical-or-flat-taxonomy

And display child terms as I answered above:
https://toolset.com/forums/topic/filter-for-taxonomies/#post-2094173

#2094223

Hierarchical doesn't work as it's not a hierarchical structure.

Topic 2 is not a subtopic of Topic 1.

Topic 1 can have related Topic 2 Topic 3 Topic 4... without them being children.

Topic 2 has its own related topics.

In other words they all same level (just like WordPress tags) but I want to relate and display the related items.

I hope this is more clear now.

#2094317

I assume you are going to setup many-to-many relationship between terms of same taxonomy "Topic".
If it is, there isn't such kind of feature within Toolset or WordPress, you might consider other workaround, for example:
1) Create a custom post type "Topic posts", register with taxonomy "Topic"
2) Add "Topic posts" posts, setup post title same as "Topic" term slug, setup related terms in taxonomy "Topic"
3) Create a post view:
- Query "Topic posts" posts
- Filter by: Post search filter
Filter post title by a search term set by the View shortcode attribute: search. eg. [wpv-view name="view-name" search="search term"]
- In view's loop, display the term's information
4) In the archive page of "Topic" taxonomy, display above post view's shortcode, for example:
[wpv-view name="view-name" search='[wpv-taxonomy-archive info="slug"]']

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-taxonomy-archive

It is only a workaround for your reference.

#2094321

Steps 3 in above answer should be a post view, edited

#2095841

My issue is resolved now. Thank you!