hey there,
i want to add this function in enfold_childs function.php in order to estimate the needed time to read an article:
/**
* Estimate time required to read the article
*
* @return string
*/
function bm_estimated_reading_time() {
$post = get_post();
$words = str_word_count( strip_tags( $post->post_content ) );
$minutes = floor( $words / 120 );
$seconds = floor( $words % 120 / ( 120 / 60 ) );
if ( 1 < = $minutes ) {
$estimated_time = $minutes . ' Minuten' . ($minutes == 1 ? '' : 's') . ', ' . $seconds . ' Sekunden' . ($seconds == 1 ? '' : 's');
} else {
$estimated_time = $seconds . ' Sekunden' . ($seconds == 1 ? '' : 's');
}
return $estimated_time;
}
But unfirtunately it breaks my site. Do you see the mistake? I really do not want to use a plugin, because most of them use the time for every page.
Please help me – and maybe you can put it as a feature to the next release :-)
tobi
Hi tobego!
You can request it here – https://kriesi.at/support/enfold-feature-requests/ :)
Can you please turn on debugging mode on – https://codex.wordpress.org/WP_DEBUG and copy the error you get?
Best regards,
Yigit
Hey Yigit, Just these two ones:
Hi!
We cannot debug the code for you as it is going to take much time you might have to hire a freelancer to do this job. however we can suggest to you to use a plugin like https://wordpress.org/plugins/estimated-post-reading-time/
Best regards,
Vinay