Php ACF不返回图像
我正在尝试使用ACF在我的一个模板页面上放置一个图像。我对变量进行了var_转储,数据就在那里。为什么我的形象没有出现?我试着用一个标签把它包起来,但没有收到任何回音。有什么建议吗Php ACF不返回图像,php,wordpress,image,advanced-custom-fields,Php,Wordpress,Image,Advanced Custom Fields,我正在尝试使用ACF在我的一个模板页面上放置一个图像。我对变量进行了var_转储,数据就在那里。为什么我的形象没有出现?我试着用一个标签把它包起来,但没有收到任何回音。有什么建议吗 <?php $first_img = get_field('image_first'); ?> <div class="panel--standard"> <div class="container contain
<?php
$first_img = get_field('image_first');
?>
<div class="panel--standard">
<div class="container container__grid">
<div class="container__col">
<h2><?php echo get_field("heading_first"); ?></h2>
<div>
<?php echo get_field($first_img['url']); ?>
</div>
<!-- <p><?php var_dump($first_img['url'])?></p> -->
</div>
<div class="container container__col">
<p><?php echo get_field("content_first"); ?></p>
</div>
</div>
</div>
可以通过几种方式设置高级自定义字段以返回数据。代码显示此图像字段设置为返回“Array”。因此,您获取它的方式是,$first_img是一个数据数组,URL是原始未剪切图像的来源。你实际上拥有的不是“图像”本身,而是数据
在这一行中,您试图使用不正确的URL重新蚀刻字段数据:
<?php echo get_field($first_img['url']); ?>
相反,您要寻找的是:
<img src="<?php echo $first_img['url']; ?>" alt="<?php echo $first_img['alt']; ?>"/>
“alt=”“/>