【问题标题】:My nested repeater isn't returning anything(Wordpress plugin ACF)我的嵌套中继器没有返回任何内容(Wordpress 插件 ACF)
【发布时间】:2014-03-03 09:43:25
【问题描述】:

我有一个中继器,我将在下面显示它不会返回任何错误,也不会返回任何内容。 (回声不起作用)

我正在尝试显示子字段 officetype,但这是设置:

Offices(repeater)->Officetypeinfo(repeater)->多个子字段(例如officetype)

谁能告诉我我做错了什么,如果你需要的比我提供的更多,请告诉我。

<?php if( get_field('offices')): ?>
    <?php while( has_sub_field('offices')): ?>
        <?php if( get_sub_field('officetypeinfo')): ?>
            <?php while( has_sub_field('officetypeinfo')): ?>
                <?php
                    $show = the_sub_field('officetype');
                       echo $show;
                       the_sub_field('officetype');
                ?>
            <?php endwhile; ?>
        <?php endif; ?>
    <?php endwhile; ?>
<?php endif; ?>

提前致谢!

【问题讨论】:

    标签: php wordpress advanced-custom-fields


    【解决方案1】:

    the_sub_field('officetype');后面不用加echo $show;

    您是否检查过您使用的字段名称是否正确? 试试var_dump('field-name'); 看看哪里出错了。

    【讨论】:

    • 我后来意识到我的结构不正确并删除了子字段 officetypeinfo 并通过同时删除它来修复我的结构。不管怎样,谢谢你当时帮助我意识到这一点。
    猜你喜欢
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 2018-10-24
    • 1970-01-01
    • 2017-01-07
    • 1970-01-01
    相关资源
    最近更新 更多