How to remove html tags from wordpress comment form

By default, WordPress includes default comment note of basic HTML tags helps in post comment form. You have probably seen –especially if you don’t install the jetpack plugin.– that note in the little text below in the comment form.

How to remove html tags from wordpress comment form

It is very simple to remove the unpleasant appearance and there are 3 different ways:

  1. By CSS
  2. By comments.php
  3. By functions.php
  1. By CSS: Open your theme’s style.css file and add this piece of code at the end of this file
    /* Paste code at the end of the style.css file */
    .form-allowed-tags{
    display: none;
    }
  2. By comments.php: Open your theme’s comments.php file find the below code.
    <?php comment_form(); ?>

    Replace this above code with the code mention below.

    <?php comment_form(array('comment_notes_after' => '')); ?>

    OR

    Find the bellow code:

    ,
          'comment_notes_after' => '<p class="help-block">' . 
                  sprintf(__('You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s', 'bootstrap-basic'), $comment_allowed_tags) . 
                  '</p>'

    Replace with the following code:

    /*,
          'comment_notes_after' => '<p class="help-block">' . 
                  sprintf(__('You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s', 'bootstrap-basic'), $comment_allowed_tags) . 
                  '</p>'*/
  3. By functions.php: Open your theme’s functions.php file and add the following code to this file:
    add_filter( 'comment_form_defaults', 'remove_comment_form_allowed_tags' );
    function remove_comment_form_allowed_tags( $defaults ) {
    
      $defaults['comment_notes_after'] = '';
      return $defaults;
    
    }

     

That’s All!

Leave a Reply