parent
bfc18a3cf6
commit
7817f3999a
2 changed files with 17 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
<article class="article container-article" id="post-<?php the_ID(); ?>">
|
<article class="article container-article" id="post-<?php the_ID(); ?>">
|
||||||
<?php if ($haveTitle) { ?>
|
<?php if ($haveTitle) { ?>
|
||||||
<h1 class="page-title"><?php the_title(); ?></h1>
|
<h1 class="page-title"><?php the_title(); ?></h1>
|
||||||
|
<p class="text-right"><span class="btn-small btn-secondary"> <?php echo reading_time(); ?> </span></p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<div class="article-entry">
|
<div class="article-entry">
|
||||||
|
|
|
@ -322,3 +322,19 @@ register_taxonomy('roman', 'post',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
add_action( 'init', 'wpb_custom_new_menu' );
|
add_action( 'init', 'wpb_custom_new_menu' );
|
||||||
|
|
||||||
|
//estimated reading time
|
||||||
|
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;
|
||||||
|
}
|
Reference in a new issue