【问题标题】:Advanced custom fields not showing repeater不显示转发器的高级自定义字段
【发布时间】:2015-02-09 00:56:32
【问题描述】:

您好,由于自定义插件,我在显示 ACF 字段时遇到了问题。 然后我发现我可以改写:

<?php $outputtext= get_field('text'); ?>
<?php echo $outputtext; ?>

而不是

<?php get_field('text'); ?>

因为激活插件时这不起作用。


所以我一直在寻找答案一段时间,并且一直在测试我确实获得字段以显示转发器的相同方式。没有成功...

是的,我一直在测试常规代码

    <?php
    // check if the repeater field has rows of data
    if( have_rows('topp_yrken_referenser') ):
        // loop through the rows of data
        while ( have_rows('topp_yrken_referenser') ) : the_row(); { ?>

            <div class="col-xs-12 col-sm-4">
               <blockquote>
                    <?php // display a sub field value
                    the_sub_field('topp_yrke_referens');
                    ?>
               </blockquote>
            </div>


       <?php } endwhile;
    else :
        // no rows found
    endif;
    ?>

这是它在自定义插件停止工作之前的工作方式

  1. 我怎样才能像我用这个来做这样的工作?

  2. 这个 $this= get_field('text'); 有名称吗? ?

【问题讨论】:

  • 没有 else/endif 是否可以工作?
  • 没有其他的几乎是一样的。没有 endif 我得到空站点,没有 else 和 endif 我得到空页面...

标签: php wordpress repeater advanced-custom-fields


【解决方案1】:
<?php if (have_rows('topp_yrken_referenser')){ ?>
     <?php while (have_rows('topp_yrken_referenser')) { the_row(); ?>
     div class="col-xs-12 col-sm-4">
               <blockquote>
                    <?php the_sub_field('topp_yrke_referens'); ?>
               </blockquote>
            </div>
     <?php }; // while:   ?>
    <?php }; ?>

这是代码所能达到的准系统。

【讨论】:

    猜你喜欢
    • 2018-05-19
    • 2018-08-26
    • 2015-04-21
    • 1970-01-01
    • 2018-04-15
    • 2018-08-18
    • 2015-08-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多