de

wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren




get_comment_excerpt [ WordPress Function ]

get_comment_excerpt ( $comment_ID = 0 )
Parameter:
  • (int) $comment_ID The ID of the comment for which to get the excerpt. Optional.
Nutzt:
Gibt zurück:
  • (string) The maybe truncated comment with 20 words or less
Definiert in:



Retrieve the excerpt of the current comment.

Will cut each word and only output the first 20 words with '...' at the end. If the word count is less than 20, then no truncating is done and no '...' will appear.

Source


<?php
function get_comment_excerpt$comment_ID ) {
    
$comment get_comment$comment_ID );
    
$comment_text strip_tags($comment->comment_content);
    
$blah explode(' '$comment_text);
    if (
count($blah) > 20) {
        
$k 20;
        
$use_dotdotdot 1;
    } else {
        
$k count($blah);
        
$use_dotdotdot 0;
    }
    
$excerpt '';
    for (
$i=0$i<$k$i++) {
        
$excerpt .= $blah[$i] . ' ';
    }
    
$excerpt .= ($use_dotdotdot) ? '...' '';
    return 
apply_filters('get_comment_excerpt'$excerpt);
}
?>

Beispiele [ wp-snippets.com ]

Top Google Suchergebnisse

Mehr ...

Nutzerduskussionen [ wordpress.org ]

0 Nutzerkommentare

Noch keine. Sei der Erste!

Neu hinzufügen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics