Let me preface this, this is only if you are creating a widget and not if you just want to add a class to an existing widget, there are plugins that do that.

It’s really actually simple, I just could not find the answer right away because it isn’t one of those things mentioned in the Widgets API section of the WordPress Codex.

The above link has this in the Example when creating a widget:

If there were one more line (like the below), then this post wouldn’t exist. The array that holds the description can also have a key of classname, which can have a string value, which is turned into your widget’s css classes.

Happy coding.

Leave a Reply

Your email address will not be published. Required fields are marked *

+ eighty eight = 89