【问题标题】:How to display acf repeater in tag archive page?如何在标签存档页面中显示 acf 转发器?
【发布时间】:2021-04-02 06:58:08
【问题描述】:

我想在标签存档页面上显示一些转发器字段。使用此代码,我可以显示 acf 的简单文本字段:

$term = get_queried_object();
$meta = get_field('test', $term);

但是当想输出acf中继器时没有成功。

$term = get_queried_object();
if (have_rows('faq', $term)) :
    while (have_rows('faq', $term)) : the_row();
        echo get_sub_field('question');
        echo get_sub_field('answer');
    endwhile;
endif;

【问题讨论】:

    标签: wordpress advanced-custom-fields taxonomy


    【解决方案1】:

    根据文档,这是它的基本代码结构。

    // Check rows exists.
    if( have_rows('repeater_field_name') ):
    
        // Loop through rows.
        while( have_rows('repeater_field_name') ) : the_row();
    
            // Load sub field value.
            $sub_value = get_sub_field('sub_field');
            // Do something...
    
        // End loop.
        endwhile;
    
    // No value.
    else :
        // Do something...
    endif;
    

    【讨论】:

    • 这是基本代码,在标签存档页面中不起作用。
    • 它有什么问题?
    猜你喜欢
    • 2020-06-23
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 1970-01-01
    • 1970-01-01
    • 2016-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多