【WordPress】ブログに『読むための所要時間』を表示する方法

Blog Marketing Up Close Blue Pen GraphicBlog Marketing Up Close Blue Pen Graphic / Maria Reyes-McDavis

こちらのサイトを参考に(ていうかそのままコピペ)させていただきました。

WordPress: 『読むための所要時間』を表示するコード書いた – Hinemosu



こちらの記事(たった一行追加するだけでサイトの滞在時間を13.8%伸ばす方法・・・ | IDEA*IDEA)によると、サイト滞在時間が伸びたとか・・・。

そこで簡単なPHPコードを書いてそれを検証、結果として13.8%、滞在時間をのばすことができたそうです。確かに記事を読むときに「まぁ、1分ぐらいだったら読むか」となるかもしれませんね。

たった一行追加するだけでサイトの滞在時間を13.8%伸ばす方法・・・ | IDEA*IDEA から引用

当ブログでは設置した結果・・・

何ら実感は得られませんでした!(涙目)(;´Д`)

記事内容の質が問われているのでしょうか。
ただ、記事のボリュームがなんとなく自分でも分かりやすくなったので、このままにしておきますわ。

で、実際の導入手順ですが。

当ブログでは
記事一覧表示(index)の場合は記事タイトル下の記事情報の下に入れています。
20110610_2

個別記事表示(single)の場合は記事タイトルのすぐ下に入れています。
20110610_1

使用したコードはこちら。

[cc lang=php]
< ?php $mycontent = $post->post_content; // wordpress users only
$word = mb_strlen(strip_tags($mycontent));
$m = floor($word / 400) + 1 ;
$est = $m . ‘分ぐらい’ ;
?>

この記事を読むのに必要な時間の目安: < ?php echo $est; ?>

[/cc]

このコードを「index.php」とか「single.php」にコピペします。
▼index.phpの場合(一部抜粋)
[cc lang=php]

< ?php if (comments_open()) : ?>< ?php comments_popup_link(('0 comments on this article‘), (‘1 comment on this article‘), (‘% comments on this article‘), ”, ”); ?>< ?php endif; ?>
Posted by
in < ?php the_category(', '); ?>
on
< ?php the_tags((', tagged with '),', ',''); ?>.

< ?php $mycontent = $post->post_content; // wordpress users only
$word = mb_strlen(strip_tags($mycontent));
$m = floor($word / 400) + 1 ;
$est = $m . ‘分ぐらい’ ;
?>

この記事を読むのに必要な時間の目安: < ?php echo $est; ?>

< ?php the_content(('Read more')); ?>


< ?php if (is_single() || is_page()) { edit_post_link(('Edit this article'), '

‘, ”); wp_link_pages(‘before=

‘); } ?>

< ?php comments_template('', true); ?>
< ?php endwhile; ?>
[/cc]
記事情報の下、ということで「”postmeta”」が終わったあとに入れています。

▼single.phpの場合(一部抜粋)
[cc lang=php]
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>

< ?php the_title(); ?>

< ?php if (is_attachment()) { ?>

← Back to < ?php $mycontent = $post->post_content; // wordpress users only
$word = mb_strlen(strip_tags($mycontent));
$m = floor($word / 400) + 1 ;
$est = $m . ‘分ぐらい’ ;
?>

この記事を読むのに必要な時間の目安: < ?php echo $est; ?>


Posted in < ?php the_category(', '); ?>
on < ?php the_time(('F jS, Y')) ?>

< ?php } ?>