Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Ashley Michèlle on "Display only manual excerpt on index (function)."

$
0
0

This is my current functions.php custom function:

function custom_excerpt($text) {  // custom 'read more' link
   if (strpos($text, '[...]')) {
      $excerpt = strip_tags(str_replace('[...]', '<div class="readmore"><a class="readmore" href="'. get_permalink( get_the_ID() ) . '"><small>CONTINUE READING</small></a></div>', $text), "<a>");
   } else {
      $excerpt = '' . strip_tags($text) . '<div class="readmore"><a class="readmore" href="'. get_permalink( get_the_ID() ) . '"><small>CONTINUE READING</small></a></div>';
   }
   return $excerpt;
}
add_filter('the_excerpt', 'custom_excerpt');

You can see it in action here: http://ohmybonbon.com.

I would like to see only the manual excerpts displayed, and if there is no manual excerpt, I would like it to only display the 'continue reading' link, rather than an automatic excerpt (as it is currently doing).

I'm sure this is probably incredibly easy, but my brain isn't working. So, of course, help is greatly appreciated!


Viewing all articles
Browse latest Browse all 8245

Trending Articles