First time than I use Timber and I'm looking for help to find a way to filter some custom_post with a taxonomy.
In this file single-news.php, I try to display in my custom posts (news) controller a link with a an acf taxonomy field named 'categorie_dexpertise' When I get it I use it in tax_query ... I try to filer 'collaborateur' post type with term_id 'categorie_dexpertise' in 'expertise-collaborateur' taxonomy But it doesn't work!
Single-news.php
<?php
$context = Timber::get_context();
$post = Timber::query_post();
$context['post'] = $post;
$context['term'] = new Timber\Term('category-news', 'news');
$expertise_team = get_field('categorie_dexpertise');
$context['expertise_team'] = $expertise_team;
$args = array(
'post_type' => 'collaborateur',
'post_status' => 'publish',
'order' => 'DESC',
'tax_query' => array(
'taxonomy' => 'expertise-collaborateur',
'field' => 'term_id',
'terms' => array(11),
),
);
$context['teamfilter'] = Timber::get_posts($args);
Timber::render('single-news.twig', $context);
Is there a better way or an alternative way to filter my custom-posts? Thank for your help :) :)