Acf 插件的值在 wordpress 中没有得到 the_field

Acf plugin's value not getting with the_field in wordpress

我想用短代码显示 acf 值,我在 function.php 文件中创建了函数,并在小部件侧边栏中添加了这个短代码,但它没有 returning value.In 图像文件我将图像 return 值设置为图像 url 但它不起作用。

1) 我在function.php 文件

中编写的代码
function myfunction() { 
?>

    <img src="<?php the_field('pop_img'); ?>" alt="no image" />

    <p><?php the_field('pop_date'); ?></p>

    <p><?php the_field('pop_btn_text'); ?></p>

<?php }
add_shortcode('display_popup','myfunction');

2) 我在小部件中得到的输出只有

 "no image"

3) 在显示带有 post id 的值时,它 return 是这样的

code: 
<?php 
        echo '<pre>';
            print_r( get_fields(8647) );
        echo '</pre>';
        // die; 
    ?>

Output:
Array
(
    [] => 
    [pop_img] => http://localhost/wordpress/wp-content/uploads/2017/10/josh-woodward-gravity-mp3-image.jpg
    [pop_date] => 20171105
    [pop_btn_text] => dsdfdscfvdsvdv
)

使用get_field()函数得到ACF值

 <?php 
    function myfunction() { 
       $popup_field_array= get_fields(8647);
        //$pop_img_path = get_field('pop_img', get_the_ID());
        $pop_img_path = $popup_field_array['pop_img'];
        $pop_date = $popup_field_array['pop_date'];
        $pop_btn_text = $popup_field_array['pop_btn_text'];
        if($pop_img_path != "")
        {
            ?>
                <img src="<?php echo $pop_img_path; ?>" alt="no image" />
            <?php
        }
    ?>
       <?php /*?> <p><?php echo get_field('pop_date', get_the_ID()); ?></p>
        <p><?php echo get_field('pop_btn_text',get_the_ID()); ?></p><?php */?>
         <p><?php echo $pop_date; ?></p>
        <p><?php echo $pop_btn_text; ?></p>
    <?php 
    }
    add_shortcode('display_popup','myfunction');
?>