我试图在我的归档页面上显示分类法中的术语,但我很难显示术语名称,以下是我目前所掌握的内容:
if ($post->post_type == \'cpt_saving\') {
$categories = get_the_terms($post->ID, \'cpt_saving-type\');
if ($categories) {
$categories[\'name\'];
}
$stack = [
\'title\' => get_field(\'savings_headline\', $post_id),
\'image\' => get_field(\'savings_supplier_logo\', $post_id),
\'reference\' => get_field(\'savings_reference\', $post_id),
\'date\' => get_the_date(\'l j F Y\'),
\'link\' => get_the_permalink(),
\'term\' => $categories->name,
];
get_template_partial(\'partials/savings/savings-item\', $stack);
}
由于我有$stack作为数组,我如何调用分类术语名称以在前端显示它?