Spread the love

We can add reading time to posts in WordPress by adding small code inside the functions file. Our client has the same requirement to add reading time and there are many plugins available with many other options but using a plugin for a small feature does not look good because it increases website load time or might conflict with any code or plugins in the website. So we have made this small function to do this.

Please add the below function inside your functions.php file of your WordPress theme, try to edit the functions file from FTP or Cpanel not edit from theme editor directly.

function post_time() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$readingtime = ceil($word_count / 200);

$timer = min;
$totalreadingtime = $readingtime . $timer;

return $totalreadingtime;

Now, print post time by echo the function inside your single.php file.

<?php echo post_time(); ?>


Geometrical Web

× Chat Now