Archived topic
Modify reading time snippet
5 replies · Started by Liran on April 11, 2021
Hey there,
How can I change this code to display 'X min Read'? (instead of 'Reading time: x minutes')
Hope this makes sense!
Hi there,
this part of the code is what displays the X min Read / X mins Read
if ($time == 1) {
return $time . ' min read';
} else {
return $time . ' mins read';
}
If you want it to say:
Reading time: x minute(s).
Then change it to:
if ($time == 1) {
return 'Reading time: '. $time . ' minute';
} else {
return 'Reading time: '. $time . ' minutes';
}
Hey David,
Sorry! I edited the link to the correct one. Can you please take another look?
No problems.
First change this line:
return $time . ' minutes';
to:
return $time . ' min Read';
Then change this line:
$output .= '<div class="read-time">Reading time: ' . tu_estimated_reading_time() . '</div>';
to:
$output .= '<div class="read-time">' . tu_estimated_reading_time() . '</div>';
Perfect.
Thank you so much!
You're welcome