• Home
  • Blog

  • Home
  • Blog

0December 31, 2014

Add a Class to the WordPress Comment Submit Button

Have you ever tried to add a custom class to the Submit button at the end of the standard WordPress comment form? It should be a very easy thing to do, but up until recently, you had to use one of several hacks to achieve this. WordPress core always did allow you to change almost all of the comment form’s elements, except for the button’s class.

As of WordPress 4.1, a patch has been accepted into core that finally allows you to change the class as easily as you could change the ID. You can read all the details on the ticket and it’s patch here: http://core.trac.wordpress.org/ticket/20446.

Now it’s very straightforward to change the class. Here’s an example that adds the classes button and radius to the button. These are defined in the Foundation framework and add a nice modern look to my Submit button.

The code is heavily documented and should be self-explanatory. It is a simple WordPress filter on comment_form_defaults that modifies an array and passes it on.

This is a very welcome change for all the WordPress developers that use front-end frameworks like Foundation or Bootstrap for their custom theme development.

Happy styling!

Filed Under: Development Tagged With: Button, Comment, WordPress

Categories

  • Development (2)

Recent Posts

  • Add a Class to the WordPress Search Button
  • Add a Class to the WordPress Comment Submit Button

Recent Comments

    Copyright © 2015 All Rights Reserved

    Site by Alain Schlesser