【发布时间】:2016-12-08 22:15:56
【问题描述】:
我正在尝试从具有自定义图像大小的 ACF 获取图像 URL 以回显到 JSON。
当我尝试查询数据时,不知道为什么它会返回 false。
这就是我所拥有的:
args = array(
'post_type' => 'people',
'post_status' => 'publish',
'posts_per_page' => -1,
'order' => 'ASC'
);
$query = new WP_Query( $args );
$people_out = array();
while( $query->have_posts() ) : $query->the_post();
$image = get_field('photo');
$size = "medium";
$img = wp_get_attachment_image_src( $image, $size );
$people_out[] = array(
'name' => get_the_title(),
'email' => get_field('email'),
'image' => $img
);
endwhile;
wp_reset_query();
echo json_encode( $people_out );
不确定使用wp_get_attachment_image_src 是否正确,或者我是否完全错误。
【问题讨论】:
标签: php json wordpress advanced-custom-fields