【问题标题】:Wordpress gallery displays all the images attached to a post/pageWordpress 图库显示附加到帖子/页面的所有图像
【发布时间】: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>

【问题讨论】:

    标签: php wordpress gallery


    【解决方案1】:

    这不是错误,这就是画廊的运作方式。它只会显示附加到帖子的图像,如果您想将已上传的图像添加到图库,则需要从“媒体”菜单将图像附加到帖子。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-21
      • 1970-01-01
      • 2023-01-07
      • 2013-07-17
      • 1970-01-01
      • 2011-10-26
      • 1970-01-01
      相关资源
      最近更新 更多