首页 文章

Wordpress库显示附加到帖子/页面的所有图像

提问于
浏览
0

在我看来,Wordpress画廊有一种奇怪的工作方式 . 我解释:

  • Wordpress图库仅在帖子中显示已在当前帖子中上传的图像 . 如果您在库中添加已在媒体库中的图像,则不会显示该图像!

  • 创建图库后,如果我从图库中删除图像,无论如何都会显示

  • 图库显示附加到帖子的所有图像(也包括缩略图和嵌入图像),尽管这些图像未包含在图库中

我把所有这些都称为错误 .

问题: Is it possible to show in the post ONLY the images (both the uploaded ones and the ones that already was in Media libray) that are included in the gallery?

Notice :没有使用短代码 [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>

1 回答

  • 0

    这不是一个错误,这就是画廊的运作方式 . 它仅显示附加到帖子的图像,如果要将已上载的图像添加到图库,则需要将图像附加到“媒体”菜单中的帖子 .

    您可以使用图库短代码显示图像,也可以使用http://www.wpcodesnipps.com/display-images-attached-post/上的代码显示图像 .

相关问题