【发布时间】:2017-01-06 11:58:41
【问题描述】:
我正在尝试使用高级自定义字段获取带有附件大小的图像 URL。该字段设置为 ID。我已经使用这种方法通过 ID 获取其他图像没有问题。然而,这个并没有拉出渲染的图像。它正在提取 ID 号并将其显示在页面上。我被难住了……
<?php
$the_query = new WP_Query( array(
'post_type' => 'listicles',
'tax_query' => array(
array (
'taxonomy' => 'visibility',
'field' => 'slug',
'terms' => 'listicles-resortsvisible',
),
),
) );
$listicleimage = the_field('listicle_featured_image', $post->ID);
$listicleimgsize = 'listicle-thumb';
$listicleimg_array = wp_get_attachment_image_src($listicleimage, $listicleimgsize);
$listicleimg_url = $listicleimg_array[0];
?>
<ul
class="row small-up-1 medium-up-2">
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li class="small-12 medium-6 column">
<img
src="<?php echo $listicleimg_url; ?>"
class="align-center" />
//THE REST OF MY CONTENT//
</li>
<?php endwhile;?>
<?php endif; ?>
</ul>
<?php wp_reset_query(); ?>
【问题讨论】:
标签: wordpress advanced-custom-fields image-size imageurl