D
D
Denis Vyazemsky2015-08-27 13:22:45
Taxonomy
Denis Vyazemsky, 2015-08-27 13:22:45

How to implement the relationship between taxonomies and categories in WordPress?

The question is, we are developing a website for food delivery on wordpress!
In our case, standard WordPress posts (post) are our products!
Headings/Categories - these are our product categories!
Introduced taxonomy (brands) - we have restaurants to which products belong (post)
When adding a product, we assign it both a heading (product category) and a brand (taxonomy brands)!
When we go to the taxonomy page (for example , sait.ru/brands/kfs) , all products related to this brand are displayed there!
Now the question itself is how to remove from the headings, categories related only to products displayed on the brand page?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
CrewCut, 2015-08-27
@CrewCut

Those. Do you want to display only posts that have a brand?

W
WordPress WooCommerce, 2015-09-08
@maxxannik

For WooCommerce, this works out of the box.
Products there products.
The categories are there like the categories of products.
Next, you can add brand props.
All the same.
Only then there are ready-made widgets called search by layers. And they are displayed facet depending on the category.
Don't overthink what's already been done.
If you write your own, then there are two ways.
The first is to get the id of all posts in the category. And then, using this array, get a list of terms of the required taxonomy. There are ready-made functions in the kernel. Look.
This is done in 10 lines of code.
But there is a suspicion that this decision at very big bases can brake.
Or maybe not.
If it slows down, you will have to write the cache. But this is more difficult.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question