post_content empty?
-
Hi all, hope someone can help (I’m *not* a developer by any stretch!).
I am using Thesis (Yoast SEO is installed) and am trying to use Brian Crays estimated reading time snippet. Here’s how I implemented. I get 0m,0s for every post.
Any ideas?
Thanks!
add_action(‘thesis_hook_before_post’, ‘est_reading_time’);
function est_reading_time ()
{
if (is_single()) {
$mycontent = $post->post_content; // wordpress users only
$word = str_word_count(strip_tags($mycontent));
$m = floor($word / 200);
$s = floor($word % 200 / (200 / 60));
$est = $m . ‘ minute’ . ($m == 1 ? ” : ‘s’) . ‘, ‘ . $s . ‘ second’ . ($s == 1 ? ” : ‘s’);
?>
<p>Estimated reading time: <?php echo $est; ?></p>
<?php
}
}
- The topic ‘post_content empty?’ is closed to new replies.