如何在 Wordpress 中显示带有短代码的子字段(图像)?

How to display sub field (image) with shortcode in Wordpress?

这些是自定义字段组成:

1 组页脚

1.1 组 Col2

1.1.1 bbcimg(这是图像 ID)

1.1.2 bbc-rss(这是 RSS 提要 ID)

我有以下显示 bbc-rss 的代码:

<div class="col-md-3">
               <?php
                $footer = get_field('footer'); // 'footer' is your parent group
                $col2 = $footer['col2']; // 'col2' is your child group
                ?>
                <div class="widget_item widget_latest sm-m-top-50">
                    <h4 id="white" class="text-white">Latest News</h4>
                    <div class="widget_latst_item m-top-30">
                        
                        <div class="item_icon"><img src="<?php bloginfo('template_directory');?>/img/rss/bbc_rss.png" alt="" /></div>
                        <div id="gris" class="widget_latst_item_text">
                            <p><?php echo $col2['bbc-rss'];?></p>

                        </div>
                    </div>
                    <div class="widget_latst_item m-top-30">
                        <div class="item_icon"><img src="<?php bloginfo('template_directory');?>/img/rss/reuters_rss.png" alt="" /></div>
                        <div id="gris" class="widget_latst_item_text">
                            <p><?php echo $col2['reuters-rss'];?></p>

                        </div>
                    </div>
                    <div class="widget_latst_item m-top-30">
                        <div class="item_icon"><img src="<?php bloginfo('template_directory');?>/img/rss/cnbc.jpg" alt="" /></div>
                        <div id="gris" class="widget_latst_item_text">
                            <p><?php echo $col2['cnbc-rss'];?></p>

                        </div>
                    </div>
                </div><!-- End off widget item -->
            </div><!-- End off col-md-3 -->

我创建了具有以下属性的图像字段 bbcimg:

并且图像已经上传到自定义字段中。见图片:

问题:

如何编写网站显示图片的逻辑?

非常感谢您!

一直在尝试使用

首先,您需要找出自定义字段中返回的内容。 在某处的代码中添加一个很好的旧 print_r

<?php print_r($col2['bbcimg']) ?>

这将打印出一组值,例如 Array( 'url' => 'http....something.jpg', 'size'=>'full', ..etc)

然后您可以确定哪个数组值为您提供图像的完整 URL。假设在这种情况下它将是一个名为 url 的字段,那么您可以按如下方式使用该值:

<div id="gris" class="widget_latst_item_text">
     <img src="<?php echo $col2['bbcimg']['url']; ?>" alt=""/>
     <p><?php echo $col2['bbc-rss'];?></p>
</div>