Witam,
Mam niestandardowy typ posta o nazwie produkt oraz taksonomię o nazwie marka. Chcę wyświetlić wszystkie powiązane produkty (related products) TYLKO z kategorii nadrzędnej (taksonomia niestandardowa)!
- Niestandardowy typ posta: Produkt
- Taksonomia: Marka
- Każdy produkt ma przypisaną wartość taksonomii: Samsung
Oto, co zrobiłem do tej pory:
<?php
$custom_taxterms = wp_get_object_terms( $post->ID, 'marka', array('fields' => 'ids' ) );
$args = array(
'post_type' => 'produkt',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'marka',
'field' => 'id',
'terms' => $custom_taxterms,
'include_children' => false
),
),
'post__not_in' => array ($post->ID),
);
$related_items = new WP_Query( $args );
if ($related_items->have_posts()) :
while ( $related_items->have_posts() ) : $related_items->the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(); ?>
<h3 class="product-title"><?php the_title(); ?></h3> ); ?></div>
</a>
<?php
endwhile;
echo '</ul>';
endif;
wp_reset_postdata();
?>
Spowoduje to wyświetlenie wszystkich produktów, w tym podkategorii, których nie chcę.
Spróbowałem z "include_children' => false" - to nie działa.
Proszę o pomoc