1

I created text widget and wordpress created some default styles it uses h2 tag and class "widgettitle". How can i change tag to h1 and remove class from it.

This is my function.php file

function home_consultation_init() {
    register_sidebar(array(
        "name" => "Home Consulatation",
        "id" => "home_consult",
        "before_widget" => "",
        "after_widget" => "",
        "before-title" => "",
        "after-title" => ""
    ));
}
  • You already have before-title and after-title parameters to achieve your goal. See register_sidebar() in the Codex. – Max Yudin Jul 25 '17 at 11:02
3

The before-title and after-title arguments passed to register_sidebar() need to use underscores:

register_sidebar(array(
    "name" => "Home Consulatation",
    "id" => "home_consult",
    "before_widget" => "",
    "after_widget" => "",
    "before_title" => "",
    "after_title" => ""
));

If you use that the titles won't have any tags. You need to provide them to the before_title and after_title arguments, like so:

register_sidebar(array(
    "name" => "Home Consulatation",
    "id" => "home_consult",
    "before_widget" => "",
    "after_widget" => "",
    "before_title" => "<h1>",
    "after_title" => "</h1>"
));

Your problem was that you were using the incorrect keys (with - instead of _), so it was using the defaults.

|improve this answer|||||
1

widget title h2 to h1 change you have change in where you register widgets. two arguments "before_title" and "after_title".

register_sidebar( array(
        'name'          => esc_html__( 'Sidebar', 'themeName' ),
        'id'            => 'sidebar-1',
        'description'   => '',
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h1 class="widget-title">',
        'after_title'   => '</h1>',
    ) ); 
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.