WordPress.org

Forums

Shut off HTML on comments (6 posts)

  1. Viqtory
    Member
    Posted 7 years ago #

    How do I disable HTML on comments? I don't like it.
    Me and my visitors wants to do <3 hearts. But I can't do that with html allowed.

    I know that it isn't possible in WordPress settings but there must be some way to shut it off in the code?

  2. Define "shut off". Do you want html to be stripped out entirely? Because that won't exactly work with <3 things, it would strip everything after the < mark.

    If you want html to be displayed as actual code, like if somebody types <b> then that actually shows up, you could add this to your theme's functions.php file:

    add_filter('pre_comment_content','wp_specialchars');

    That will convert all <'s into &lt;'s and so forth, making it not html anymore.

  3. Viqtory
    Member
    Posted 7 years ago #

    Oh that is exactly what I mean! Thank you very much.

  4. moshu
    Member
    Posted 7 years ago #

    Me and my visitors wants to do <3 hearts

    That tells me you want the "smiley" thing. Search.

  5. Viqtory
    Member
    Posted 7 years ago #

    Noo i dont wanna do smileys! I want to do as it shows! Like when you type <b> is shall be like that. I dont want them to do any html at all, just plain text.

    And I do not have an functions.php in my theme, what do i do then?

  6. And I do not have an functions.php in my theme, what do i do then?

    Create one. Make a text file. Put this in it:

    <?php
    add_filter('pre_comment_content','wp_specialchars');
    ?>

    Make sure that it has NO blank lines or spaces at the top (before the <?php) or at the bottom (after the ?>). Everything in the file must be inside the ? lines.

    Then rename the file to functions.php and upload it to your theme directory.

Topic Closed

This topic has been closed to new replies.

About this Topic