• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

Change Widget Title Tags From H4 To H2

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.

Another example:

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.

Register for full access

Related Tutorials

  • Conditionally Wrap Genesis Featured Posts Widget Title In Span Tags
  • Change Genesis Widget Area Title HTML Tag
  • Modify The Widget Title of Any Widget

Genesis Featured Posts

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.