Any way to limit comment length?

  • Unknown's avatar

    I have a clearly-stated policy limiting comments to 250 words, yet I occasionally have to delete essays. This is a bit heart-breaking (readers put so much work into it) and I don’t like to do it, but my discussion threads would become unmanageable otherwise.

    I know this is a long shot, but is there any way to cap comments at a certain number of words/characters (much as Twitter does when you’re writing tweets)? That way commenters would know when they are reaching the limit. Thanks.

    The blog I need help with is: (visible only to logged in users)

  • Hm – I wish I could answer this differently, but I’m afraid word counting/limiting is outside of CSS’s capabilities.

    I notice you’ve included <250 words in the comment title – if you want, you can use CSS to add an additional message.

    Here’s an example:

    .comment-form-field.comment-textarea:after {
        display: block;
        content: "Remember to keep your comment under 250 words, or it will not be posted!";
        font-size: 20px;
        padding: 5px 10px;
        color: red;
        font-style: italic;
        text-align: center;
    }

    That might be a little more intense than you want on your site, but I wanted to get you some ideas :).

    You can change the word after to before if you’d like it on top of the comment box (instead of below). You can also change the color using HTML color codes, adjust the font size – anything you like.

    CSS won’t let you add a link (in case you’re wondering about linking to your comment policy page) but you can spell it out a bit if you think that would help! :)

  • Unknown's avatar

    That’ll work. Thanks Chad.

    On a related note, this is the fourth bit of code I have added to my CSS box and I’m keen to add more. (The power!) But at what point do these extra bits of code start having an adverse effect on page-load times?

    Could I add 20 little bits of code without a noticeable effect? 50? How much is too much?

  • You’re welcome!

    In terms of how much CSS is too much, don’t worry about page loads – things like image files and fonts and other large items will be more likely to have an impact :)

    Many themes have hundreds, if not thousands of lines of CSS, so no worries!

  • Unknown's avatar
  • The topic ‘Any way to limit comment length?’ is closed to new replies.