使用“高级自定义字段”插件,我为每个帖子类别添加了一个名为“颜色”的字段,效果很好。
现在,在循环中,我需要检索“color”字段的值,我已经学习了许多其他教程,但我无法获得所需的结果。
以下是如何设置循环的示例:
while ( $projects->have_posts() ) {
$projects->the_post();
$category_classes = array();
$categories = get_the_terms( get_the_ID(), \'project_category\' );
if ( $categories ) {
foreach ( $categories as $category ) {
$categories_included[] = $category->term_id;
}
}
现在,在完美的场景中,我需要在foreach循环中获取类别的“颜色”。非常感谢您的帮助或指导。