Wordpress从图库中排除特色图片

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wordpress从图库中排除特色图片相关的知识,希望对你有一定的参考价值。

This snippet will exclude the featured image from the attached images (gallery)
  1. <?php
  2. $thumb_ID = get_post_thumbnail_id( $post->ID );
  3. if ( $images = get_children(array(
  4. 'post_parent' => get_the_ID(),
  5. 'post_type' => 'attachment',
  6. 'post_mime_type' => 'image',
  7. 'exclude' => $thumb_ID,
  8. ))) : ?>
  9. <ul>
  10. <?php foreach( $images as $image ) : ?>
  11. <li><?php echo wp_get_attachment_link($image->ID, 'thumbnail-latest'); ?></li>
  12. <?php endforeach; ?>
  13. </ul>
  14. <?php else: // No images ?>
  15. <!-- This post has no attached images -->
  16. <?php endif; ?>

以上是关于Wordpress从图库中排除特色图片的主要内容,如果未能解决你的问题,请参考以下文章