この機能は、Raindrops1.248以降で動作します。(2014/10/20現在、最新バージョンは1.246です。将来の機能です)
アイキャッチ画像がセットされている場合、ループページのタイトルの前に、アイキャッチのサムネールが表示されますが、セットされていない場合には、添付画像を表示する。それもない場合、デフォルト画像がセットされていれば、デフォルト画像を表示するようにカスタマイズします。
functions.phpにコードを追加
add_filter('raindrops_title_thumbnail','extend_thumbnail',10,3 ); function my_single_attachment_image( $post_id= '', $default_image_url='', $width= 48, $height= 48) { global $post; if ( empty( $post_id ) && isset( $post->ID )){ $post_id= $post->ID; } $args = array( 'post_type' => 'attachment', 'post_mime_type'=> 'image', 'numberposts' => 1, 'post_parent' => $post_id, ); $images = get_children($args); if( empty($images) && !empty($default_image_url)){ return ''; } elseif ( ! empty( $images ) && is_array( $images ) ) { return wp_get_attachment_image( key( $images ), array( $width, $height ) ); } } function extend_thumbnail( $thumbnail ,$pre, $after){ global $post; if( empty( $thumbnail ) && in_the_loop() ){ return $pre. my_single_attachment_image('', 'https://www.tenman.info/images/pen.jpg' ). $after; } return $thumbnail; }