Changing header tag in side bar

I would like to change the header tag in side bar in child theme. h3 to h4.
I appreciate if someone can show me the code.
Thanks.

Hi,

Thank you for reaching out to us. I am happy to help with your queries.

I need more information:

  1. Can you share a link to your website here?
  2. Can you point me to the location you need help with by mentioning what the text reads?

Regards,
Kharis
aThemes Support

Hi Kharis,

Thank you very much for the quick response.
Here is the link to our website: https://pollockfirm.com/blog/
I would like to change the title of sidebar widget “Archives” and " Categories".
I tried to insert a code in function.php file in child theme. However, website went down.
The code I inserted is:

    function sydney_widgets_init() {
      register_sidebar( array(
      	'name'          => __( 'Sidebar', 'sydney' ),
      	'id'            => 'sidebar-1',
      	'description'   => '',
      	'before_widget' => '<aside id="%1$s" class="widget %2$s">',
      	'after_widget'  => '</aside>',
      	'before_title'  => '<h4 class="widget-title">',
      	'after_title'   => '</h4>',
      ) );
    }

Hi,

Thank you for getting back along with the requested information and the code.

Remove that sydney_widgets_init() function and replace it with this:

    function sy_child_customize_widget_title_tag( $params ) {

        $sidebar_location = $params[0]['id'];

        if( 'sidebar-1' == $sidebar_location ) {
          $params[0]['before_title'] = '<h4 class="widget-title">' ;
          $params[0]['after_title']  = '</h4>' ;
        }

        return $params;

    }
    add_filter( 'dynamic_sidebar_params' , 'sy_child_customize_widget_title_tag' );

Regards,
Kharis
aThemes Support

It worked! Thank you so much!!!

Would you kindly show me the similar code for the Footer widget areas?

Thank you.

You’re welcome!

Try replacing the last code I suggested with:

    function sy_child_customize_widget_title_tag( $params ) {

       $sidebar_location = $params[0]['id'];

       if( 'sidebar-1' == $sidebar_location ) {
         $params[0]['before_title'] = '<h4 class="widget-title">' ;
         $params[0]['after_title']  = '</h4>' ;
       }

       $widget_areas = get_theme_mod('footer_widget_areas', '3');
       for ($i=1; $i<=$widget_areas; $i++) {
    		 if( 'footer-' . $i == $sidebar_location ) {
           $params[0]['before_title'] = '<h4 class="widget-title">' ;
           $params[0]['after_title']  = '</h4>' ;
         }
       }    

       return $params;

    }
    add_filter( 'dynamic_sidebar_params' , 'sy_child_customize_widget_title_tag' ); 

Regards,
Kharis
aThemes Support

It worked. Thank you!!!

1 Like

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis
aThemes Support