Contents
How to change the default title of a widget?
Define your widget as follows: It’s important that the before_title and after_title defaults are removed. After some trial and error I noted that the first filter that showed a default title was widget_title. Then use the widget_title filter like so:
Can you add a jQuery around the title of a widget?
Yes you can add an around the title of the widget, you do this in the register_sidebar code which you would put in your functions.php You create the new “widget area” or sidebar which you then put in actual widget in. You would then add the jQuery either to a JS file and Enqueue it or put it into wp_footer using the filter of the same name ( link)
Can a widget be wrapped twice with a Div?
As mentioned in the comments, some core widgets add their own title which then gets wrapped twice with the content div. To remove them, you could simply return an empty string. The only downside is that you have to enter all the titles manually. Correct me if I’m missing something here, but I think that’s quite solid.
Register a sidebar with regular way: As mentioned in the comments, some core widgets add their own title which then gets wrapped twice with the content div. To remove them, you could simply return an empty string. The only downside is that you have to enter all the titles manually.
How to wrap a widget with a Div?
Then use the widget_title filter like so: Basically, is my before_title and is my after_title. Finally, use dynamic_sidebar_params to prepend a closing div for our content wrap:
How does WordPress generate sidebar ID and name?
WordPress will automatically generate a sidebar ID and name based on the current number of registered sidebars if those arguments are not included. When allowing for automatic generation of the name and ID parameters, keep in mind that the incrementor for your sidebar can change over time depending on what other plugins and themes are installed.