Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,30 @@ function _s_scripts() {
if ( class_exists( 'WooCommerce' ) ) {
require get_template_directory() . '/inc/woocommerce.php';
}

/**
* Add Post Reading time.
*/
function post_read_time() {

// get the post content
$content = get_post_field( 'post_content', $post->ID );

// count the words
$word_count = str_word_count( strip_tags( $content ) );

// reading time itself
$readingtime = ceil($word_count / 200);

if ($readingtime == 1) {
$timer = " minute read";
} else {
$timer = " minute read"; // or your version :) I use the same wordings for 1 minute of reading or more
}

// I'm going to print 'X minute read' above my post
$totalreadingtime = $readingtime . $timer;
echo $totalreadingtime;
return $totalreadingtime;

}