php - archive.php 上带有画廊字段的 WordPress ACF 选项组返回 NULL
问题描述
我对archive.php 的ACF 有一个小问题。我有一个 ACF 组,其中包含一些字段。例如画廊领域。
问题是画廊字段返回NULL,有人知道如何解决这个问题吗?
这行代码有效并返回值。所以我不知道为什么画廊领域不起作用
<?php the_field('header_block_size', 'options');?>
这就是我想出的。
<section id="page-header" class="page-header page-header--<?php the_field('header_block_size', 'options');?>">
<?php $images = the_field('header_block_images', 'options'); ?>
<?php var_dump($images);?>
<?php if($images): ?>
<div class="page-header__carousel">
<?php foreach($images as $image): ?>
<div class="page-header__inner" style="background-image: url('<?php echo esc_url($image) ?>')">
</div>
<?php endforeach; ?>
</div>
<div class="page-header__heading">
<h1 class="page-header__heading-title"><?php the_field('header_block_title', 'options');?></h1>
<div class="page-header__heading-border"></div>
<?php if(get_field('header_block_filter', 'options') === true): ?>
<div class="page-header__filter">
<?php echo do_shortcode('[searchandfilter fields="post_tag" submit_label="Check out the tours"]'); ?>
</div>
<?php endif;?>
</div>
<?php endif ; ?>
</section>
我希望有人知道如何解决这个问题。
提前致谢。
我用<?php var_dump(get_fields());?>
代替编辑了代码<?php var_dump($images);?>
,它返回array(1) { ["rating"]=> float(4) }
我还使用图库字段添加了一个新图像。
解决方案
推荐阅读
- django - 引导按钮菜单响应在 Django 项目中不起作用
- javascript - 使用 css 和 javascript 淡出元素在页面中留下空白空间
- json - ssis 输出 json 文件添加额外的 crlf
- c - 在字符串中的每个逗号后添加双引号
- php - 当需要服务器响应时,消除确认对话框的等待时间
- javascript - How to search data in a table in HTML
- regex - Rust regex pattern - unrecognized escape pattern
- android - Ionic:使用 cordova-plugin-inappbrowser 拦截 PDF URL
- javascript - 解析 Javascript 变量
- python - Finding Sequence and splitting it to array with Python