Support

Account

Home Forums ACF PRO Count Words from different fields in differents row layouts Reply To: Count Words from different fields in differents row layouts

  • Found a solution for me with array_push:

    
    if ( have_rows( 'module_post') ):
    
    $stackWords = array();
    
     while ( have_rows( 'module_post') ) : the_row();
    
      if ( get_row_layout() == 'module_text' ) : // Text
    
    	$content = get_sub_field( 'module_post' );
    	array_push($stackWords, $content);
    	
      endif;
    
     endwhile;
    
    $words = implode( ", ", $stackWords );
    $word_count = str_word_count( strip_tags( $words ) );
    //$readingtime = ceil($word_count / 200);
    //echo $word_count;
    
    endif; //module_post
    

    If there a better solution, let me know. thank you!