[Resolved] Sidebar Widgets to H3 on some pages

Home Forums Support [Resolved] Sidebar Widgets to H3 on some pages

Home Forums Support Sidebar Widgets to H3 on some pages

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #675566
    vodryy

    Hi,
    I need help with change of Widgets H2 headings to H3, but I want to change to H3 only on homepage, categories, archives and tags pages. On single Pages and Posts leave H2.

    I tried to use this following code to change it only on categories, but without success. It breaks all widget headings on all pages.

    add_filter( ‘generate_start_widget_title’,’generate_widget_title_h3′ );
    function generate_widget_title_h3()
    {
    if ( is_category() )
    return ‘<h3 class=”widget-title”>’;
    }
    add_filter( ‘generate_end_widget_title’,’generate_widget_title_end_h3′ );
    function generate_widget_title_end_h3()
    {
    if ( is_category() )
    return ‘</h3>’;
    }

    Could you please help with that.

    Jiri

    GP Premium 1.7.2
    #675907
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this:

    add_filter( 'generate_start_widget_title', function( $title ) {
        if ( is_category() ) {
            return '<h3 class="widget-title">';
        }
    
        return $title;
    } );
    
    add_filter( 'generate_end_widget_title', function( $title ) {
        if ( is_category() ) {
            return '</h3>';
        }
    
        return $title;
    } );

    Let me know ๐Ÿ™‚

    #676524
    vodryy

    Hi Tom,
    thank you for code. But it did not anything.
    Widgets on all pages are with heading H2.
    Tried this code with is_category and than separately with is_home.
    Category pages and in the next try the home page are showing H2 as all other pages.
    Tried to change variable $title to something else (to try if it is not coliding with other snippet).
    Without success.

    Best Regards

    Jiri

    #676809
    Tom
    Lead Developer
    Lead Developer

    Let’s try this instead:

    add_action( 'wp', function() {
        add_filter( 'generate_start_widget_title', function( $title ) {
            if ( is_category() ) {
                return '<h3 class="widget-title">';
            }
    
            return $title;
        } );
    
        add_filter( 'generate_end_widget_title', function( $title ) {
            if ( is_category() ) {
                return '</h3>';
            }
    
            return $title;
        } );
    } );
    #676881
    vodryy

    Hi Tom,
    It is still not changing widgets titles to H3.

    Best Regards
    Jiri

    #677271
    Tom
    Lead Developer
    Lead Developer

    Can you link me to one of your category pages where it should be working?

    #678396
    vodryy

    Hi Tom,
    I will try to rebuild my seo strategy.
    Thank you very much for your effort.
    Have a nice day

    Jiri

    #678642
    Tom
    Lead Developer
    Lead Developer
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.