Those last days I have had a recurrring request on how to remove the text describing the HTML tags allowed in comments : “You may use these HTML tags and attributes …“.
This is pretty simple to remove this note in WordPress since it is declared in an array assigned to a hook. You just need to hook in the ‘comment_form_default_fields’ array and set your desired custom value or just an empty string.
Check the source code here.
The Html tag text is declared with the comment_note_after key of the array(). That’s the one that will be modified in the following code snippet.
add_filter('comment_form_defaults' , 'remove_allowed_html_tags_note', 30); function remove_allowed_html_tags_note( $defaults ) { //returns the modified array return array_replace( $defaults, array('comment_notes_after' => '' ) ); }
This code has to be pasted in your functions.php. More about customizing your WordPress theme.
33 thoughts on “Removing the allowed HTML tags and attributes note after the comment form in WordPress”
Great Article
thank for share http://qncherbalgroup.com/obat-tumor-otak-di-apotik/ to article i am http://goo.gl/j93PPm terbantu for to articel you
Very Cool….Very Impressive! Thanks for sharing!
http://www.hotelsline.net
Use plugin Remove Comment Notes to remove this notes.its effective and common now a days
Thank you so much for the wonderful information.
You can use plugin Remove Comment Notes to remove this notes.
Thanks for your contribution Dejan.
If you look at the code of that plugin it uses exactly, and nothing more – except for the fact that it uses a oop pattern -, the same code 😉
Great. Thanks.
Thanks for the tip. Just removed the code form my blog. Good one !
I tried putting the script above, but yet could be lost under the code comments. Do I misplaced it? Please guidance, thanks
Hi ulya,
If you are new to WordPress development, please make sure you read those guidances first :
How to customize the Customizr theme ?
You’ll also want to get help from the user community in the support forum.
worked just when i’m login, so i got this css line en style.css (on child theme) to make it work:
#form-allowed-tags {
display: none;
}
maybe is not the best way to do it but it worked, seeya.
This filter just remove the notes but not restrict the users to use elements so what is solution to restrict users to use html tags?
Is this CSS short-cut safe to use?
I’m still testing this theme. Not quite ready to make a child theme yet.
nice share , tnx
Thanks for sharing your post, glad to read
Worked great! Thank you!
This is so helpful! Thanks.
Removing the allowed HTML tags and attributes note after the comment form in WordPress is a tricky for WordPress developers. I hope after take a reference this blog new developers can easily remove the HTML tags and attribute.
Thanks for sharing!
It work well.. Thank you..
Hmmm, it hasn’t taken it off my posts. I pasted this in my theme functions php of my child theme.
add_filter(‘comment_form_defaults’ , ‘remove_allowed_html_tags_note’, 30);
function remove_allowed_html_tags_note( $defaults ) {
//returns the modified array
return array_replace( $defaults, array(‘comment_notes_after’ => ” ) );
}
I refreshed my page and the tags and attributes are still under the comment box.
another simple way is to
to replace this:
with this: ”)); ?>
in your themes comment.php
Thank you very much for this tip! I have it inserted in the function.php of my new WordPress theme and it works great! Cheers from webongo in Teningen, Germany!
Great, I am glad it helped!
Thank you. There are a couple of other snippets out there but this one is the simplest and works perfectly. Cheers.
Worked great! Thank you!
After wasting like 30 mins in fixes i found this… just pasted
add_filter(‘comment_form_defaults’ , ‘remove_allowed_html_tags_note’, 30);
function remove_allowed_html_tags_note( $defaults ) {
//returns the modified array
return array_replace( $defaults, array(‘comment_notes_after’ => ” ) );
}
in functions.php and fixed everything, thanks a lot 😉
dude thank you !!!
Hello while trying to get rid of the html tags and attributes I messed up the code and well now I get this error
Parse error: syntax error, unexpected ‘}’ in /home2/groldan/public_html/wp-content/themes/make/functions.php on line 250
It won’t allow me to even log in to my blog or anything. The site won’t even load.
Hi Gabriel,
I recommend this link to debug the theme :http://www.presscustomizr.com/customizr/diagnosing-problems-customizr/
Those common php mistakes page could also be useful : http://codex.wordpress.org/User:Skippy/Common_PHP_Errors
Best
when i past this code the whole comment box is removed
That’s weird, it should work fine like that. It’s been tested and worked without any issues.
Make sure you don’t miss a piece of code when pasting?
Best