Wordpress不在帖子中显示图像

时间:2015-05-06 13:59:05

标签: php wordpress image custom-fields

我有自定义字段(单张图片)。 我返回Object Image。 我的代码是:

$post_single_image = get_post_field( 'single_image', $post_id );
<?php if($post_single_image!=''): ?>
<div class="art-image-sing" >
     <?php echo do_shortcode($post_single_image); ?> 
</div>

但是wp会返回我的id图像。 我试图更改网址图片,但是wp返回id图像

除了图像ID,我怎样才能得到任何东西?

1 个答案:

答案 0 :(得分:0)

您必须使用此类代码

$post_single_image = get_post_field( 'single_image', $post_id );
<?php if($post_single_image!=''): ?>
<div class="art-image-sing" >
     <?php echo do_shortcode([$post_single_image]); ?> 
</div>
必须在do_shortcode([$ post_single_image])中提及

do_shortcode