我已经设置了一个名为“tours”的自定义帖子类型,其分类法“tour_category”仅特定于该帖子类型。在分类中,我设置了 4 个区域 Golf Breaks、Walking Tours 等......我想要实现的是将 Golf Breaks Taxomony 中的所有帖子渲染到 golf.twig 模板中,但我似乎得到的只是一个页面发现错误。有人可以用这个例子指出我正确的方向吗?
$context = Timber::get_context();
$args = array(
// Get post type tours
'post_type' => 'tours',
// Get all posts
'posts_per_page' => -1,
// get post in "Golf Breaks" category
'meta_query' => array(
array(
'key' => 'tour_category',
'value' => 'Golf Breaks',
'compare' => 'LIKE'
)
),
// Order by post date
'orderby' => array(
'date' => 'DESC'
));
$context['Golf Breaks'] = Timber::get_posts( $args );
Timber::render( 'golf.twig', $context );