2 posts by 2 authors in: Forums > CMS Builder
Last Post: March 21, 2017   (RSS)

By Zicky - March 21, 2017

Hey zip222,

Give this a try. You'll need to modify the record referenced and your max words count for your needs... but it should do the trick. I use it in the same manner.

Add MAX Words above your  <!DOCTYPE HTML>.

// MAX Words
function maxWords($textOrHtml, $maxWords) {  
  $text  = strip_tags($textOrHtml, " ");  
  $words = preg_split("/\s+/", $text, $maxWords+1); 
  if (count($words) > $maxWords) { unset($words[$maxWords]); }  
  $output = join(' ', $words);  
  return $output;  



Add as you meta description, and replace "$aboutRecord" with your appropriate record info.

<meta name="description" content="<?php echo maxWords($aboutRecord['content'], 32); ?>" />