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!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.