ソースを参照

Merge pull request #1185 from sharazghouri/master

Independent Publisher 2:  if post word less than 250 words  post show 0 minutes time to read solved.
Michael Cain 5 年 前
コミット
6556a4c2b0
1 ファイル変更4 行追加0 行削除
  1. 4 0
      independent-publisher-2/functions.php

+ 4 - 0
independent-publisher-2/functions.php

@@ -129,6 +129,10 @@ function independent_publisher_2_word_count() {
 	$content = get_post_field( 'post_content', get_the_ID() );
 	$content = get_post_field( 'post_content', get_the_ID() );
 	$count   = str_word_count( strip_tags( $content ) );
 	$count   = str_word_count( strip_tags( $content ) );
 	$time    = $count / 250; //Roughly 250 wpm reading time
 	$time    = $count / 250; //Roughly 250 wpm reading time
+	// if time less than 1 explicitly set to 1.
+	if( $time < 1 ) {
+		$time = 1;
+	}
 	return number_format( $time );
 	return number_format( $time );
 }
 }
 endif; // independent_publisher_2_word_count
 endif; // independent_publisher_2_word_count