我正在抓取我的图库图像的URL:
$gallery = get_post_gallery_images( $post );
foreach($gallery as $thumbnail) {
echo $thumbnail_slideshow;
}
问题是我得到的只是缩略图:image1-150x150.jpg
image2-150x150.jpg
image3-150x150.jpg
我想得到:image1-600x100.jpg
image2-600x100.jpg
image3-600x100.jpg
当然,我在函数中定义了自定义image\\u大小。php:add_image_size( \'mysize\', 660, 100, true );
我想知道是否有可能用get_post_gallery( $post )
或者应该创建某种循环?Here\'s a great answer by Otto, 不幸的是,它对我不起作用(我试图使它在single-customposttype.php中工作,它不显示任何内容,替换为$post->ID
具有$page->ID
或$parent->ID
显示媒体库中的所有内容)。
更新看起来我不太明白什么是对的。
我在很多地方都看到过一个片段,也在上面奥托的帖子中看到过:
$gallery_images = new WP_Query(array(
\'post_parent\' => $post->ID,
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
\'post_status\' => \'inherit\',
));
while ( $gallery_images->have_posts() ) : $gallery_images->the_post();
the_title();
the_content();
the_permalink();
endwhile;
我把它粘贴到内容中。你猜怎么着?它不返回任何内容,当然,这篇文章有gallery和get\\u post\\u gallery\\u images($post)完美地处理它。我做错了什么?当然,当我上传图片到图库时,上面的代码是有效的,因为图片是直接上传/附加到这篇文章的。当然,我的其他所有图像都是“(未附加的)”,这可能是一个问题。。。