Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Resolved] Changing Sidebar h tags.

Home Forums Support Changing Sidebar h tags.

  • This topic has 22 replies, 4 voices, and was last updated 2 years ago by Tom.
Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #142905
    Mo

    Hi again Tom,
    Is there anyway to change the h tags without using the child theme.
    Same concern as with the footer.php file.
    There’s the possibility of missing out on important updates.

    I tried using the hooks but immediately broke the sidebars.
    No shock there:)

    Thanks,
    Mo

    #142910
    Tom
    Lead Developer
    Lead Developer
    #143201
    Mo

    Sorry Tom,
    Added the snippet to the functions.php file but nothing happened.

    Edited sidebar files are in the child theme and work as they should.

    It’s not a matter of removing the tags, it’s replacing them with any heading desired.

    Without the default sidebar widget-title is an h3.

    Not sure what heading to finalize but the option to change them is my goal.

    Can this still be done using the functions file?

    #143222
    Tom
    Lead Developer
    Lead Developer

    The widgets should be H4 tags, not H3.

    They have built in filters so the below PHP will change it from H4 to a div:

    add_filter( 'generate_start_widget_title','generate_remove_widget_title_h4' );
    function generate_remove_widget_title_h4()
    {
          return '<div class="widget-title">';
    }
    
    add_filter( 'generate_end_widget_title','generate_remove_widget_title_end_h4' );
    function generate_remove_widget_title_end_h4()
    {
          return '</div>';
    }

    Confirmed to be working on my end.

    Have you customized the call to the widgets at all?

    #143257
    Mo

    These snippets are from the current GP parent theme v1.3.15:
    sidebar.php:

    <aside id="archives" class="widget">
    						<h3 class="widget-title"><?php _e( 'Archives', 'generate' ); ?></h3>
    						<ul>
    							<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
    						</ul>
    					</aside>
    
    					<aside id="meta" class="widget">
    						<h3 class="widget-title"><?php _e( 'Meta', 'generate' ); ?></h3>

    sidebar-left.php:

    <aside id="archives" class="widget">
    						<h3 class="widget-title"><?php _e( 'Archives', 'generate' ); ?></h3>
    						<ul>
    							<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
    						</ul>
    					</aside>
    
    					<aside id="meta" class="widget">
    						<h3 class="widget-title"><?php _e( 'Meta', 'generate' ); ?></h3>

    Neither has been altered by me nor has the call been changed.

    Just to make certain, I downloaded 1.3.15 and checked it.
    The sidebar.php and sidebar-left.php have a widget-title of H3 tag.

    ===

    I get it after searching the files.

    The h4 tags are in the functions.php file so that’s where the modification is made in the child theme.

    When I check the source code of the current website, the widget titles are h3.

    That’s what’s confusing.

    Is the functions.php widget-title code supposed to override what’s in the sidebar files?

    Thanks.

    #143267
    Tom
    Lead Developer
    Lead Developer

    Ah, those are just the default widget placeholders. Those shouldn’t even appear on your site once you’ve added to own widgets.

    Thanks for pointing that out though – I’ve made them h4s in the next version.

    When you add your own widgets to the widget areas, are the titles changed to divs?

    #143290
    Mo

    Sorry Tom,
    I got sidetracked on the Scroll to Top mod.
    I’ll check out the snippet you’ve posted and get back to you.

    Thanks for the speedy response though.

    #143292
    Mo

    Just took a look after adding the snippets to the functions.php in the chold theme.

    No change.

    Source code shows this:

    left-sidebar:

    <aside id="archives" class="widget">
    <h3 class="widget-title">Archives</h3>

    right-sidebar:

    <aside id="archives" class="widget">
    <h3 class="widget-title">Archives</h3>
    #143339
    Tom
    Lead Developer
    Lead Developer

    What happens when you add your own widget to one of those sidebar areas in “Appearance > Widgets”?

    #143347
    Mo

    Just added a custom widget.
    It returned an H4 tag on the widget-title.

    #143353
    Mo

    Hi Tom,

    After checking around at current SEO info on sidebar widget, the H tag strength is indeed correct at an H4 tag or possibly an H5.

    Therefore, I won’t be changing anything on the sidebars.

    Apologies if this has created any inconvenience for you.

    Thanks for checking.

    #143380
    Tom
    Lead Developer
    Lead Developer

    Glad that works for you now.

    I’ve fixed the default widgets to include H4 tags instead of H3 as well.

    That filter should work for you to turn the H4 into a div – not sure what’s going on there.

    Thanks!

    #143442
    Mo

    Hey Tom,
    I re-added the modified widget code.

    The H tags have been replaced with DIVS so the code does work.

    Perhaps it has something to do with the H3 tags being applied to the default widgets that are displayed if no custom widgets are added.

    When the next update comes out, I can re-check that the code still produces the desired results.

    Removing the custom widget from the right sidebar resulted in the default widgets appearing (Search, Archives, Meta).

    Their widget-titles were once again H3.

    When the next update comes out, I’ll re-check that the code still produces the desired results.

    Thanks.

    #143492
    Tom
    Lead Developer
    Lead Developer

    The update will show the default widgets as H4s now 🙂

    Thanks!

    #143501
    Mo

    Excellent.

    It’s also nice to have that custom code if one decides to go with just DIVS.

    Thanks.

Viewing 15 posts - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.