In this tutorial, i’ll provide the PHP code you can use with any theme to change the text displayed before and after your comments form.
By default, WordPress generates comment notes that include text before and comment form allowed tags after your form which you may want to remove or customize.
Here’s the default form :
And here’s an example of what you can do simply by adding the code at the end of your child themes functions.php file and customizing the text in the code:
Here’s the code which i have modified as per the screenshot above:
One benefit of using this code is that it removes the comment form allowed tags. You can also achieve this by installing this plugin.
Its very easy to style because the code includes the comments-notes class which you can paste at the end of your child themes style sheet and add your own declarations.
You can also change the comments-notes class in the PHP code above if you want to style the before and after notes differently.
.comment-notes {
color: blue;
}
The code in this tutorial enables you to easily modify the default text and add a comment form policy, HTML or pretty much anything else.
Other Options
- Customize Comment Form Place Holder Input Text Fields & Labels
- Remove Comments From Specific Posts and Different Categories
- Customize Comment Form Text Area & Label
- Style Comment Form Submit Button
Pretty basic stuff, what do you think?
Great, thank you very much, appreciate!
No worries.
Brad, thank you so much for posting this! I literally just had this question the other day and was going to make a post on a forum asking how to accomplish this! Instead, I find someone posted a link to a few of your tutorials, and bam – my question already answered here! 🙂
Mind answering a new question though? Do you have any code that I could add to make commenters’ website links open in a new window? I know it just needs the target=”_blank” code, but I wouldn’t know how to make a custom php to do that…? (I’m using Dynamik Website Builder, and if you have a php option like the above code, I could just easily add it in the custom functions section like I did with this code you gave here!)
No worries Anthony
I’ll email you the link to the code.
Hi Brad, I would be interested, too, in this code. Thanks.
Just published a new post with the code Chris.
Great tipps, thanks a lot, exactly what I need right now!
No worries Chris
Brad, excellent piece of code. I got this added and works perfectly.
Thanks Derek.
Also works with any theme as it uses the WordPress filter hooks rather than any theme specific hooks.