The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How to add ellipsis? Reply To: How to add ellipsis?


I always use my own function to show an excerpt of something, based on the number of words.

The function (put this in your function.php or custom plugin file):

function custom_excerpt($limit,$moreText = '') {
  $excerpt = explode(' ', get_the_excerpt(), $limit);
  if (count($excerpt)>=$limit) {
    if ($moreText) {
      $excerpt = implode(" ",$excerpt).'... <a href="'.get_the_permalink().'" class="read-more">'.$moreText.'</a>';
    } else {
      $excerpt = implode(" ",$excerpt).'...';
  } else {
    $excerpt = implode(" ",$excerpt);
  $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
  return $excerpt;

Within the loop, call it using:

echo custom_excerpt(40);

Or something like:

echo custom_excerpt(35,'Read full article');