外贸营销

wordpress首页或分类,输出文章内的多张图片
2019.09.06 外贸营销

对于图片类网站,这个功能可谓极为实用的。整体美观度大大提高。这个功能很早就有人实现,可是读取的是文章原图。因为是分类和首页,调用很多原图会导致用户消耗大量流量及时间去加载非常不实用。现在这个问题我们得到了很完美的解决,依赖timthumb来获取所有缩略图。请使用了上面介绍的timthumb获取缩略图功能后在使用下方函数。

wordpress首页或分类,输出文章内的多张图片

<?php$args = array('post_type' => 'attachment','numberposts' => 3,//读取文章图片数量'post_status' => null,'post_parent' => $post->ID,'post_mime_type' => 'image','order' => 'ASC','orderby' => 'menu_order','exclude' => array (get_post_thumbnail_id()));$attachments = get_children( $args );if ( $attachments ) {foreach($attachments as $v){echo '<img class="lazy-hidden QQ colorbox-36492"  src="//www.babylyf.com/wp-content/plugins/a3-lazy-load/assets/images/lazy_placeholder.gif" data-lazy-type="image" data-src="' . get_template_directory_uri() . '/timthumb.php?src=';echo '&h=150&w=200&q=90&zc=1&ct=1" alt="' . get_the_title() . '" >';="" }="" }?>="" <="" pre=""><noscript><img class="QQ colorbox-36492"  src="' . get_template_directory_uri() . '/timthumb.php?src=';echo '&amp;h=150&amp;w=200&amp;q=90&amp;zc=1&amp;ct=1" alt="' . get_the_title() . '" />';}}?>//</pre/></noscript>
上一篇下一篇
标签

有问
必答