【发布时间】:2013-03-09 08:38:51
【问题描述】:
在我看来,Wordpress 画廊的工作方式很奇怪。我解释一下:
Wordpress 图库仅在帖子中显示已发布的图片 在当前帖子中上传。如果您在图库中添加一张图片 已经在媒体库中,不会显示!
创建图库后,如果我从图库中删除图像 无论如何都会显示它
图库显示附加到帖子的所有图像(也 特色缩略图和嵌入图像)虽然这些图像是 不包含在图库中
我将所有这些称为错误。
问题:是否可以在帖子中只显示图库中包含的图片(上传的图片和媒体库中的图片)?
注意:不使用短代码[gallery exclude="..."],也不直接从媒体库上传图片?
附:要在帖子中显示画廊,我正在使用此脚本:
<ul>
<?php $images = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID . '&orderby=menu_order&order=ASC');
foreach( $images as $img_id => $img_r ) :
$thumb = wp_get_attachment_image_src( $img_id, 'thumb', true );
$full = wp_get_attachment_image_src( $img_id, 'full', true ); ?>
<li>
<a href="<?php echo $full[0] ?>">
<img src="<?php echo $thumb[0] ?>" alt="<?php echo get_the_title( $img_id ) ?>" title="<?php echo get_the_title( $img_id ) ?>">
</a>
</li>
<?php endforeach; ?>
</ul>
【问题讨论】: