- This topic has 7 replies, 2 voices, and was last updated 3 years, 8 months ago by
Tom.
-
AuthorPosts
-
September 12, 2018 at 9:09 am #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.2September 12, 2018 at 7:22 pm #675907Tom
Lead DeveloperLead DeveloperHi 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 ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 13, 2018 at 9:18 am #676524vodryy
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
September 13, 2018 at 6:50 pm #676809Tom
Lead DeveloperLead DeveloperLet’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; } ); } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 13, 2018 at 10:12 pm #676881vodryy
Hi Tom,
It is still not changing widgets titles to H3.Best Regards
JiriSeptember 14, 2018 at 8:10 am #677271Tom
Lead DeveloperLead DeveloperCan you link me to one of your category pages where it should be working?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 16, 2018 at 4:31 am #678396vodryy
Hi Tom,
I will try to rebuild my seo strategy.
Thank you very much for your effort.
Have a nice dayJiri
September 16, 2018 at 9:59 am #678642Tom
Lead DeveloperLead DeveloperYou too ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.