- This topic has 22 replies, 4 voices, and was last updated 5 years, 6 months ago by Tom.
-
AuthorPosts
-
October 8, 2015 at 4:03 pm #142905Mo
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,
MoOctober 8, 2015 at 4:33 pm #142910TomLead DeveloperLead DeveloperHi Mo,
This should help: https://generatepress.com/forums/topic/h-tags/#post-126407
October 9, 2015 at 6:18 pm #143201MoSorry 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?
October 9, 2015 at 11:24 pm #143222TomLead DeveloperLead DeveloperThe 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?
October 10, 2015 at 7:20 am #143257MoThese 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.
October 10, 2015 at 8:37 am #143267TomLead DeveloperLead DeveloperAh, 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?
October 10, 2015 at 9:51 am #143290MoSorry 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.
October 10, 2015 at 10:00 am #143292MoJust 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>
October 10, 2015 at 5:43 pm #143339TomLead DeveloperLead DeveloperWhat happens when you add your own widget to one of those sidebar areas in “Appearance > Widgets”?
October 10, 2015 at 5:59 pm #143347MoJust added a custom widget.
It returned an H4 tag on the widget-title.October 10, 2015 at 6:08 pm #143353MoHi 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.
October 10, 2015 at 10:42 pm #143380TomLead DeveloperLead DeveloperGlad 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!
October 11, 2015 at 6:39 am #143442MoHey 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.
October 11, 2015 at 10:38 am #143492TomLead DeveloperLead DeveloperThe update will show the default widgets as H4s now 🙂
Thanks!
October 11, 2015 at 11:34 am #143501MoExcellent.
It’s also nice to have that custom code if one decides to go with just DIVS.
Thanks.
-
AuthorPosts
- You must be logged in to reply to this topic.