WordPress.org

Ready to get started?Download WordPress

Forums

apply comment excerpt (2 posts)

  1. canutedechou
    Member
    Posted 3 years ago #

    im trying to show the last 2 comments from a post
    but, i want to apply a excerpt to a comment
    the problem is, i have the next function, but any time i want to apply the excerpt, it doesnt show anything

    <?php $comments = get_comments('post_id=' . $post->ID . '&number=2');
    		if($comments) {
    		foreach($comments as $comment) :
    		echo($comment->comment_author .
    		' says: <br />' . $comment->comment_content . '<br />'); endforeach;
    		} ?>

    and where it says $comment->comment_content i need to put the excerpt
    any idea?
    thanks

  2. canutedechou
    Member
    Posted 3 years ago #

    i just solved with these

    <?php $comments = get_comments('post_id=' . $post->ID . '&number=2');
    		if($comments) {
    		foreach($comments as $comment) :
    		echo('<div class="author">' . $comment->comment_author .
    		' says: </div><div class="comment-excerpt">' . get_comment_excerpt( $comm->comment_ID ) . '</div>');
    		endforeach;
    		} ?>

    i leave the code if someone needs it

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.