分类(类别)中的 ACF 中继器不起作用

Tom*_*ter 1 wordpress advanced-custom-fields acfpro

在分类类别中,我有:

中继器字段命名为问题。在中继器内,我有一个名为answer的字段。

我试图在category.php 文件中显示所有答案,如下所示:

$term = get_queried_object();

if ( have_rows( 'questions',   $term ) ) {
    while( have_rows( 'questions',   $term ) ) {
        the_row();
        the_sub_field( 'answer' );
    }
}
Run Code Online (Sandbox Code Playgroud)

这不起作用。你能告诉我这里出了什么问题吗?我已经尝试了几个小时才让它发挥作用。

小智 5

如果有人仍在寻找解决方案,我就是这样做的。

            <?php 
                $term = get_queried_object();
                $taxonomy = $term->taxonomy;
                $term_id = $term->term_id;  
                if( have_rows('highlight_boxes', $taxonomy . '_' . $term_id) ):
                while(have_rows('highlight_boxes', $taxonomy . '_' . $term_id)): 
                the_row(); 
            ?> 

                <div class="column">
                    <h2 class="heading-title"><?php the_sub_field('highlight_title', $taxonomy . '_' . $term_id) ?></h2>
                    <div class="description">
                        <p><?php the_sub_field('highlight_desc', $taxonomy . '_' . $term_id) ?></p>
                    </div>
                </div>
            
            <?php endwhile; endif; ?>  
Run Code Online (Sandbox Code Playgroud)