【问题标题】:ACF content is empty in fancyboxFancybox 中的 ACF 内容为空
【发布时间】:2019-12-28 04:35:27
【问题描述】:

我已将 ACF 设置为调用到一个花式框。它正在拉入字段(因为我可以看到硬编码的标头信息),但没有来自 ACF。我已将链接设置为调用 ID,然后将其分配给单击时要调用的部分。

我希望单击图像并打开精美框,其中 ACF 图像和内容显示在精美框中。我得到的是标题字段,没有 acf 内容。

我已尝试从课程中删除显示 none。

我尝试编写一个调用 p 的基本 a 标签,这似乎可以工作,但是当我输入 ACF 信息时,它会中断。

我还删除了所有的 php,只是硬编码在图像和内容中,它可以工作。它只是不喜欢调用我的 ACF 的 php。

<a href="#popup" data-fancybox>               
            <img class="image" src="<?php the_field('project_image', get_the_ID()); ?>" />
        </a>
<section id="popup">
            <img src="<?php the_field('project_image', get_the_ID()); ?>">
                    <h3>About</h3>
                    <p><?php echo $about_content;?></p>
                        <hr class="hr-left">
                        <h3>Features</h3>
                    <p><?php echo $features_content; ?></p>
                    <a class="btn secondary-btn" href="<?php echo $code_reference_url; ?>"><?php echo $button_text; ?></a>
</section>

点击图片时,会打开一个精美的框,并在“弹出”div 中显示内容。发生的事情是它打开了灯箱并填充了空字段。

【问题讨论】:

    标签: javascript wordpress fancybox advanced-custom-fields


    【解决方案1】:

    我能够解决这个问题。我没有在循环内操作的信息。请参阅下面的解决方案:

    <?php while ($loop->have_posts()) : $loop->the_post();
                    $about_content = get_field('about_content');
                    $features_content = get_field('features_content');
                    $button_text = get_field('button_text');
                ?>
    

    【讨论】:

      猜你喜欢
      • 2019-12-19
      • 1970-01-01
      • 2019-04-25
      • 2022-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多