我正在尝试从单个帖子中获取所有图库图像。在 get_post_gallery()
中,变量 $image
返回缩略图 URL。谁能帮我从帖子中检索完整尺寸的图像 URL。
$gallery = get_post_gallery(get_the_ID(), false )
foreach( $gallery['src'] as $image ) {
$image_list . = '<li>' . $image . '</li>';
}
最佳答案
这对我有用:
$gallery = get_post_gallery( $post, false );
$ids = explode( ",", $gallery['ids'] );
foreach( $ids as $id ) {
$link = wp_get_attachment_url( $id );
$image_list . = '<li>' . $link . '</li>';
}
感谢 Matt 提供此代码,请参阅 original post
关于php - get_post_gallery 全尺寸图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21915610/