WordPress.org

Ready to get started?Download WordPress

Forums

Widget comment excerpts (1 post)

  1. alexleonard
    Member
    Posted 7 years ago #

    Hi there,

    I was just working on creating a widget that would give me greater control over the display of recent comments. One of the main things I wanted was to have the first 20 words or so of the comment displayed underneath the author or post title.

    I spent some time looking through the codex and comparing code from around the place and it seemed to me that I wouldn't be able to use the template tag "comment_excerpt" as this was not clicking with the MySQL columns (I think).

    In the end I've temporarily used:

    substr($comment->comment_content , 0, 100)

    Which just takes the first 100 characters from the comment_content, but this means that words get chopped in half etc.

    Is there any easy way to make sure I only get whole words?

Topic Closed

This topic has been closed to new replies.

About this Topic