Ограничение заголовка по количеству символов или слов

по количеству символов:

function trim_title_chars($count, $after) {<div style="float:right;width:350px;margin:0 0 10px 15px;">
<div id="yandex_rtb_R-A-187781-2"></div>
</div>
          $title = get_the_title();
          if (mb_strlen($title) > $count) $title = mb_substr($title,0,$count);
          else $after = '';
          echo $title . $after;
}

по количеству слов:

function trim_title_words($count, $after) {
          $title = get_the_title();
          $words = split(' ', $title);
          if (count($words) > $count) {
                    array_splice($words, $count);
                    $title = implode(' ', $words);
          }
          else $after = '';
          echo $title . $after;
}