communityfield’s diary

サイト開発のメモです。メモなので結構適当です

bbpressのtopicにアイキャッチ画像を設定する

コミュニティサイトを作ったものの、いまいち味気ない

はてなブックマークさんみたいなアイキャッチ画像を入れたいなと

以下のプラグインを使えばbbpressのトピックにアイキャッチ画像を設定できそう

wordpress.org

ただあまりプラグインで対応したくないのでテーマファイルを編集することにした

bbpressのloop-single-topic.phpにsimplicityのアイキャッチ画像を入れ込んだ

<figure class="entry-thumb">
<?php if ( has_post_thumbnail() ): // サムネイルを持っているとき ?>
<a href="<?php the_permalink(); ?>" class="entry-image entry-image-link" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'thumb150', array('class' => 'entry-thumnail', 'alt' => get_the_title()) ); ?></a>
<?php else: // サムネイルを持っていない ?>
<a href="<?php the_permalink(); ?>" class="entry-image entry-image-link" title="<?php the_title(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/no-image.png" alt="NO IMAGE" class="entry-thumnail no-image list-no-image" /></a>
<?php endif; ?>
</figure><!-- /.entry-thumb -->

あとはcssだけ少しいじり動作が確認できた