Answer the question
In order to leave comments, you need to log in
How to display posts in wordpress given two taxonomies?
In general, there is a custom post type (PRODUCT), it has two taxonomies (STATUS and MODEL).
I just can’t figure out how to display records of this format on the STATUS page:
MODEL - name
- PRODUCT
- PRODUCT
MODEL - name -
PRODUCT -
PRODUCT
--
i.e. so that the STATUS page displays all taxonomies MODEL and under each model a list of PRODUCTS with the same status and model
Answer the question
In order to leave comments, you need to log in
I looked down, drank and decided
Maybe it will come in handy for someone:
1. Created a separate template for the taxonomy "STATUS" ( taxonomy-statuses.php )
2. Created a cycle that displays all MODELS
3. Inside the MODELS cycle where model data is displayed, there is another cycle that displays PRODUCTS
First two items are standard. The third one can cause problems:
$productsArg = array(
'post_type' => 'product', // тип записей ТОВАРы
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'main_product', // ТОВАР должен быть в этой МОДЕЛИ которая выводится
'field' => 'id',
'terms' => array( $modal->term_id )
),
array(
'taxonomy' => 'statuses', // и с тем же статусом
'field' => 'id',
'terms' => $thisStatusID
)
)
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question