先日は、Popular-post プラグインにサムネイルを足したのですが同じように「Post-Views」プラグインでのウィジェットにもサムネイルをつけてみました。
| [Wordpress]「人気記事」のウィジェットにサムネイル画像を付ける | Roguer |
ある上記の記事で参考にしてほしいのはCSSの箇所です。この箇所は同じになるようにしています。
post-viewsのプラグインの 2260行目を以下のように修正しています。出力結果は上記の Popular-postでの書き出しにあわせています。これでサムネイルが表示されていい感じに表示されますね。「Popular-post」よりも「Post-Views」の方が柔軟に表示が出来るので利便性はあると思います。
![[Wordpress]「人気記事」のウィジェットにサムネイル画像を付ける | Roguer.jpg Wordpress 人気記事 のウィジェットにサムネイル画像を付ける | Roguer](http://roguer.info/wp-content/uploads/2012/05/40321c3c634abbba85e3093c796b2bfc.jpg)
wp-content/plugins/post-views/post-views.php
1 2 | $thum=get_the_post_thumbnail( $post->ID , array(64,64) ); $pv_views[$count] = array('title' => '<div class="popular_posts"><a href="'.get_permalink().'" class="dashedline">'.$thum.'<div class="popular_posts_title">'.$post_title.'</ div></a></div><div style="clear:both"></div>', 'views' => number_format($post_views), 'time' => $view_time, 'post_id' => $post->ID ); |
style.css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | .wp-post-image { border:solid 1px #ccc; padding: 4px; float: left; margin-left: -80px; margin-bottom: 10px; /* vertical-align: text-top; */ } .popular_posts { padding: 3px; margin-top: 3px; margin-left: 80px; } .popular_posts_title { margin:2px auto; font-size: 90%; } .popular_posts_snippet { margin:2px auto; font-size: 75%; color: #A0A0A0; } |
実際の効果のほどは分かっていませんが画像を表示するようにしてから若干滞在時間が増えたので見てくれている人が増えている気がします。やはり視覚に訴えるのは重要ですね。


















