【发布时间】:2012-08-18 15:06:55
【问题描述】:
我目前有一些 php 代码可以获取随机 Wordpress 帖子的缩略图,但问题是当我运行它时,直到每张图片都被下载后才会显示任何图像。我想知道是否有办法回显图像然后转到下一个。谢谢。
<?php
$args = array( 'numberposts' => 25, 'orderby' => 'rand' );
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );?>
<li id="photo-<?php the_ID(); ?>" class="visible scroll-content-item ui-widget-header"><a href="<?php the_permalink(); ?>"><img width="80" height="80" src="<?php echo $url; ?>" class="attachment-small-grid wp-post-image" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /></a> </li>
<?php endforeach; ?>
【问题讨论】: