This code enables you to change the h4 heading tag widget titles are wrapped in to h2 or any other other heading tag like this:
The code includes a value for the
$widget_name variable which you can change to target any type of widget like the text widget or search widget. You can also change the classes the widget title is wrapped in by default.
To find the name of your widget, look in the file for the code which uses the __construct function and you’ll find the 2nd parameter is the name of the widget you need to use in the code to target a specific widget.
Here’s an example:
parent::__construct( 'text', __( 'Text' ), $widget_ops, $control_ops );
In the above code, the 2nd parameter is the name of the widget ‘Text’ which you can use in the code below to change the h4 tags the text widget title is wrapped in.
parent::__construct( 'featured-post', __( 'Genesis - Featured Posts', 'genesis' ), $widget_ops, $control_ops );
The named of the widget in the above code is ‘Genesis – Featured Posts’ which you can use in the code below to target that widget and change the tags the genesis featured posts title is wrapped in.
Tested using the WordPress default text widget and the Genesis featured posts widget.
Here’s the code for logged in members.
Leave a Reply
You must be logged in to post a comment.