Enhance post cards with date, reading time, and comment count metadata
This commit is contained in:
@@ -39,6 +39,17 @@ function wisdom1_scripts() {
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'wisdom1_scripts' );
|
||||
|
||||
/**
|
||||
* Calculate estimated reading time.
|
||||
*/
|
||||
function wisdom1_reading_time() {
|
||||
$content = get_post_field( 'post_content', get_the_ID() );
|
||||
$word_count = str_word_count( strip_tags( $content ) );
|
||||
$reading_time = ceil( $word_count / 200 ); // Average 200 words per minute
|
||||
|
||||
return $reading_time . ' min read';
|
||||
}
|
||||
|
||||
/**
|
||||
* Customizer additions.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user