这个get_post_meta() 函数可以帮助获取元字段,但不会检索不同大小的字段。
假设_pf_photo1 嵌入附件id,可以执行以下操作:
// Note the "_id" suffix
$attachment_id = get_post_meta($post->ID, \'_pf_photo1_id\', true);
此函数的最后一个参数不能为“medium”,
现在,您可以使用$attachment_id 根据您真正想要获取的内容(url、img元素…)使用不同的功能:
$attachment_element = wp_get_attachment_image( $attachment_id, \'medium\' );
echo $attachment_element;
有更多方法可以获取附件的详细信息
wp_get_attachment_url(),
wp_get_attachment_image_src (返回一个包含url、宽度和高度的数组)。
您将找到更多详细信息来发现这些功能here
希望有帮助!