在附件页上,我想显示所有属于父帖子的图像,所以应该有一个缩略图库。正在使用。。。
$parent = get_post_field( \'post_parent\', get_the_ID() );
$gallery = get_post_gallery( $parent, false );
。。。使用起来有点奇怪。为什么ID与src分开?我如何获得缩略图的ID来获取永久链接?即使我用一些复杂的核心来工作,它也会感觉脏兮兮的。难道没有更好的解决方案吗?
array (size=3)
\'columns\' => string \'4\' (length=1)
\'ids\' => string \'8844,8853,8498,8845,8846,8847,8848,8849,8852,8854,8843,8851,8855,8499,9672,9673\' (length=79)
\'src\' =>
array (size=16)
0 => string \'http://localhost/biljke/wp-content/uploads/2015/05/uljana-repica-251-200x200.jpg\' (length=80)
1 => string \'http://localhost/biljke/wp-content/uploads/2015/05/uljana-repica-33-200x200.jpg\' (length=79)
2 => string \'http://localhost/biljke/wp-content/uploads/2015/05/uljana-repica-13-200x200.jpg\' (length=79)
3 => string \'http://localhost/biljke/wp-content/uploads/2015/05/uljana-repica-26-200x200.jpg\' (length=79)
我需要这样的东西
<?php foreach($gallery as $img) : ?>
<a href="<?php echo get_permalink($img->ID); ?>">
<img src="<?php echo $img->src ?>" alt=" -<?php echo $img->title " />
</a>
<?php endforeach; ?>
还有
get_post_gallery_images()
但它只返回缩略图URL