先日メモしたwordpressプラグイン「Thumbnail for Excerpts」ですが、
get_posts()をつかったループ内だと画像が変わらないので
試行錯誤とりあえずの対処をメモします。
最初に行ったget_posts()
<?php $myposts = get_posts('numberposts=5&category=4'); foreach($myposts as $post) : setup_postdata($post); ?> <div class="dotline clearfix"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <p><?php the_excerpt();?></p> </div> <?php endforeach; ?>
get_postsで読み込みたいカテゴリ記事を指定して
ループで出力してます。
この場合、バグなのだろうか、ループ内の画像が全て同じになってしまいます。
対処後
<?php query_posts('cat=3&limit=5'); if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="dotline clearfix"> <a href="<?php the_permaLink(); ?>"><?php the_title(); ?></a><?php echo '<p>'.the_excerpt().'</p></div>'; endwhile; endif; wp_reset_query(); ?>
query_posts()にて拾うように変更しました。
これでなんとか表示されましたけどー・・
なにか納得いかない。。(笑)