wordpress的ACF设置图像,api调用url结果是id

2024-06-07
function post_featured_image_json($data,$post,$context){
    $featured_image_id = $data->data['featured_media'];
    $featured_image_url = wp_get_attachment_image_src($featured_image_id,'medium');
    if($featured_image_url){
        $data->data['featured_image_url'] = $featured_image_url[0];
    }
	$data->data['touxiang_url'] = get_field('touxiang',$post->id);   //如此就解决问题了
    return $data;
}
add_filter('rest_prepare_post','post_featured_image_json',10,3);
add_filter('rest_prepare_doctor','post_featured_image_json',10,3);  //rest_prepare_doctor就可以获取doctor类型内容
相关内容
最新

坚持的力量

wordpress建站,视频剪辑拍摄,动画制作