Wordpress the_field()路径包括数组


wordpress the_field() path including array

嘿,伙计们,我是wordpress开发的新手,我遇到的问题是,我使用高级自定义字段上传到wordpress帖子的文件返回的路径似乎在路径内输出一个数组。我的代码如下,请帮助,如果你可以。我还有一整晚要睡,所以我要经常登记。

这是我得到的文件路径:217,,des-desk-icon,,, image/png, http://localhost:8888/Wordpress%20development/wp-content/uploads/2016/08/des-desk-icon.png, 279, 279, Array

<?php while ( have_posts() ) : the_post(); ?>
                <h1><?php the_field('title'); ?></h1>
                <p><?php the_field('description'); ?></p>
                <?php if(get_field('column_description')): ?>
                    <div class="column_1">
                        <div class="column_1_image">
                        <img src="<?php the_field('column_1_image'); ?>"/>  
                        </div>
                        <div class="column_1_description">
                        <p><?php the_field('column_description'); ?></p>
                        </div>
                    </div>
                <?php endif; ?>
                <?php if(get_field('column_2_description')): ?>
                    <div class="column_2">
                        <div class="column_2_image">
                            <img src="<?php the_field('column_2_image'); ?>"/>
                        </div>
                        <div class="column_2_description">
                            <p><?php the_field('column_2_description'); ?></p>
                        </div>
                    </div>
                <?php endif; ?>
            <?php endwhile;?>

尝试一下代码,它会工作的。

ACF将以数组格式返回图像,您必须使用get_field()并使用数组格式打印它。

<?php while ( have_posts() ) : the_post(); ?>
    <h1><?php the_field('title'); ?></h1>
    <p><?php the_field('description'); ?></p>
    <?php if(get_field('column_description')): ?>
        <div class="column_1">
            <div class="column_1_image">
            <?php
                $col1_image =get_field('column_1_image');
            ?>    
            <img src="<?php echo $col1_image['url']; ?>"/>  
            </div>
            <div class="column_1_description">
            <p><?php the_field('column_description'); ?></p>
            </div>
        </div>
    <?php endif; ?>
    <?php if(get_field('column_2_description')): ?>
        <div class="column_2">
            <div class="column_2_image">
                <?php
                $col2_image =get_field('column_2_image');
                ?> 
                <img src="<?php echo $col2_image['url']; ?>"/>
            </div>
            <div class="column_2_description">
                <p><?php the_field('column_2_description'); ?></p>
            </div>
        </div>
        <?php endif; ?>
<?php endwhile;?>