23 lines
519 B
PHP
23 lines
519 B
PHP
|
<?php
|
||
|
/////////////////////////////////////////////////////////////////////////////
|
||
|
// Reading time
|
||
|
// Return the average reading time of an article
|
||
|
//
|
||
|
// Version 0.1
|
||
|
|
||
|
function reading_time() {
|
||
|
$content = get_post_field( 'post_content', $post->ID );
|
||
|
$word_count = str_word_count( strip_tags( $content ) );
|
||
|
$readingtime = ceil($word_count / 200);
|
||
|
|
||
|
if ($readingtime == 1) {
|
||
|
$timer = " minute";
|
||
|
} else {
|
||
|
$timer = " minutes";
|
||
|
}
|
||
|
$totalreadingtime = $readingtime . $timer;
|
||
|
|
||
|
return $totalreadingtime;
|
||
|
}
|
||
|
|
||
|
?>
|