Widget Title – How to Change Default H Tags?

Community Forums Forums General Discussion Widget Title – How to Change Default H Tags?

This topic is: not resolved

This topic contains 11 replies, has 4 voices, and was last updated by  samw 8 months, 2 weeks ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #80486

    sdbroker
    Participant
    Post count: 106

    Does anyone know the reason why ALL the default widget titles on Genesis themes are marked with an H4 tags? Better yet, how can I change those from the default H4 to let’s say H2?

    For SEO purposes it doesn’t make sense to have pages or posts with H2 headings inside an H4 title tag.

    Thank you!

    #80487

    genwrock
    Member
    Post count: 739

    Try this code in functions.php file of your child theme

    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    add_action( 'genesis_sidebar', 'genesis_do_custom_sidebar' );
    
    function genesis_do_custom_sidebar() {
    
    	if ( ! dynamic_sidebar( 'sidebar' ) && current_user_can( 'edit_theme_options' )  ) {
    		genesis_custom_widget_area_content( __( 'Primary Sidebar Widget Area', 'genesis' ) );
    	}
    
    }
    
    function genesis_custom_widget_area_content( $name ) {
    
    	echo genesis_html5() ? '<section class="widget widget_text">' : '<div class="widget widget_text">';
    	echo '<div class="widget-wrap">';
    	
    		printf( '<h2 class="widgettitle">%s</h2>', esc_html( $name ) );
    		echo '<div class="textwidget"><p>';
    		
    			printf( __( 'This is the %s. You can add content to this area by visiting your <a href="%s">Widgets Panel</a> and adding new widgets to this area.', 'genesis' ), $name, admin_url( 'widgets.php' ) );
    		
    		echo '</p></div>';
    	
    	echo '</div>';
    	echo genesis_html5() ? '</section>' : '</div>';
    
    }

    See My PRO Genesis Child Themes | Need Genesis Developer? | Follow Me on Twitter

    #80494

    sdbroker
    Participant
    Post count: 106

    Thanks for the quick reply @genwrock! Tried the code above but it didn’t work. Titles still show with H4 tag headings.

    Take a look at this example on the Agency Pro demo http://demo.studiopress.com/agency/

    The headings “Our Work” & “Recent Articles” that are the featured posts widget titles are marked with H4 tags. Inside those H4 tags are the articles with H2 headings. I’m under the impression that enclosing higher H tags within lower H tags is a big NO for SEO.

    The same is true not only on the Agency Pro theme but on ALL the G child themes that I looked at.

    #80543

    emasai
    Participant
    Post count: 738

    There must be rhyme to their reason and I would think that the page structures the h tags hierarchically according to their relevance to the home page. Once you get to the actual post the hierarchy changes. Maybe this article will help http://www.hobo-web.co.uk/headers/


    Need Website Customization or a Responsive CSS fix? Contact Me
    Lynne emasai.com

    #80565

    genwrock
    Member
    Post count: 739

    Ok. Please remove my code from functions.php. It was for primary sidebar.

    some how you can send me the code of functions.php file? I’ll take a look.


    See My PRO Genesis Child Themes | Need Genesis Developer? | Follow Me on Twitter

    #80577

    sdbroker
    Participant
    Post count: 106

    @emasai Thanks for the link, I don’t know if you noticed but the video that he talks about the H tag syntax errors is almost 5 years old.. so it’s totally irrelevant today that Google even pays attention to spelling. An H2 tag should never be inside an H4.
    Not sure if that’s an oversight from Genesis but it’s bad for SEO.

    @genwrock The h4 tag is by default on ALL Genesis child themes, that’s why I point you to the demo link above. Look at the functions.php on any of the child themes that you have, also look at the front-page.php on any child theme that uses widgets to input content on the front page. It’s not specific to a custom theme.

    The quick and dirty fix that I use until this is solved, I hardcode H1 or H2 tags in front-page.php right before the genesis_widget_area and I never input a title on a featured page, post or portfolio widget.

    Hopefully someone here knows a code that can fix this or StudioPress will address it as I think that it’s a major flow.

    #80578

    genwrock
    Member
    Post count: 739

    Right now I have not agency pro theme. For that reason I asking the code. But you can pass this ‘before_title’ => ‘<h2 class=”widget-title”>’ and ‘after_title’ => ‘</h2>’ in genesis_register_sidebar() function


    See My PRO Genesis Child Themes | Need Genesis Developer? | Follow Me on Twitter

    • This reply was modified 10 months, 2 weeks ago by  genwrock.
    • This reply was modified 10 months, 2 weeks ago by  genwrock.
    #80668

    sdbroker
    Participant
    Post count: 106

    @genwrock Ok, I see! I tried that last code in both functions.php & front-page.php with no results.

    Below is the corresponding functions.php & front-page.php code for the newest theme Modern Portfolio (http://demo.studiopress.com/modern-portfolio/) which also has the same issue (includes h2 headings INSIDE the h4 main title that comes from the widget) .

    Corresponding Portfolio widget code in functions.php file:

    //* Register widget areas
    genesis_register_sidebar( array(
    	'id'          => 'home-portfolio',
    	'name'        => __( 'Home - Portfolio','mpp' ),
    	'description' => __( 'This is the portfolio section of the homepage.','mpp' ),
    ) );

    Corresponding Portfolio widget code in front-page.php file:

    /**
     * Add widget support for homepage. If no widgets active, display the default loop.
     *
     */
    function mpp_home_genesis_meta() {
    
    	if ( is_active_sidebar( 'home-portfolio' ) ) {
    
    		// Force content-sidebar layout setting
    		add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
    
    		// Add mpp-home body class
    		add_filter( 'body_class', 'mpp_body_class' );
    
    		// Remove the navigation menus
    		remove_action( 'genesis_after_header', 'genesis_do_nav' );
    		remove_action( 'genesis_after_header', 'genesis_do_subnav' );
    
    		// Remove the default Genesis loop
    		remove_action( 'genesis_loop', 'genesis_do_loop' );
    
    		// Add homepage widgets
    		add_action( 'genesis_loop', 'mpp_homepage_widgets' );
    
    	}
    
    }
    
    function mpp_body_class( $classes ) {
    
    	$classes[] = 'mpp-home';
    	return $classes;
    	
    }
    
    function mpp_homepage_widgets() {
    
    	genesis_widget_area( 'home-portfolio', array(
    		'before' => '<div id="portfolio"><div class="wrap">',
    		'after'  => '</div></div>',
    	) );
    
    }

    Something similar is on the Agency them but instead of Portfolio uses the “Featured Posts” widget and also on every other theme that uses widgets to input content on the front page either using the “Featured Posts”, “Portfolio” or text widgets. When you input the widget title, it is marked up with an H4 tag that should be either an H1 (for HTML5 themes or H2 for everything else).

    #80698

    genwrock
    Member
    Post count: 739

    Then you can replace the following code

    //* Register widget areas
    genesis_register_sidebar( array(
    	'id'          => 'home-portfolio',
    	'name'        => __( 'Home - Portfolio','mpp' ),
    	'description' => __( 'This is the portfolio section of the homepage.','mpp' ),
    ) );

    WITH THIS WAY

    //* Register widget areas
    register_sidebar( array(
    	'id'          => 'home-portfolio',
    	'name'        => __( 'Home - Portfolio','mpp' ),
    	'description' => __( 'This is the portfolio section of the homepage.','mpp' ),
           'before_widget' => '<section id="%1$s" class="widget %2$s"><div class="widget-wrap">',
    	'after_widget'  => '</div></section>',
           'before_title' => '<h2 class="widget-title">',
           'after_title' => '</h2>'
    ) );

    See My PRO Genesis Child Themes | Need Genesis Developer? | Follow Me on Twitter

    #80801

    sdbroker
    Participant
    Post count: 106

    This worked like a charm even on text widgets. Thank you soooo much for all your help!

    Since this was fixed for my purposes, I should marked it as resolved… but I won’t with the hope that StudioPress will address this issue on its release of the Genesis framework which is where it should be addressed.

    #80849

    genwrock
    Member
    Post count: 739

    You are Welcome.


    See My PRO Genesis Child Themes | Need Genesis Developer? | Follow Me on Twitter

    #90251

    samw
    Participant
    Post count: 55

    Hi

    I also need to do this for all Outreach Pro widget titles as they are wrapped in H4 tags. I tried adding this

    ‘before_widget’ => ‘<section id=”%1$s” class=”widget %2$s”><div class=”widget-wrap”>’,
    ‘after_widget’ => ‘</div></section>’,
    ‘before_title’ => ‘<h2 class=”widget-title”>’,
    ‘after_title’ => ‘</h2>’

    But it’s not working – think the number and order of widgets is more complex for the theme
    It uses footers, featured pages, sub footers and sidebars

    From Outreach Pro Home Page.PHP

    add_action( ‘genesis_meta’, ‘outreach_home_genesis_meta’ );
    /**
    * Add widget support for homepage. If no widgets active, display the default loop.
    *
    */
    function outreach_home_genesis_meta() {

    if ( is_active_sidebar( ‘home-top’ ) || is_active_sidebar( ‘home-bottom’ ) ) {

    //* Force full-width-content layout setting
    add_filter( ‘genesis_pre_get_option_site_layout’, ‘__genesis_return_full_width_content’ );

    //* Add outreach-pro-home body class
    add_filter( ‘body_class’, ‘outreach_body_class’ );

    //* Remove breadcrumbs
    remove_action( ‘genesis_before_loop’, ‘genesis_do_breadcrumbs’ );

    //* Remove the default Genesis loop
    remove_action( ‘genesis_loop’, ‘genesis_do_loop’ );

    //* Add home top widgets
    add_action( ‘genesis_loop’, ‘outreach_home_top_widgets’ );

    //* Add home bottom widgets
    add_action( ‘genesis_before_footer’, ‘outreach_home_bottom_widgets’, 1 );

    }

    }

    function outreach_body_class( $classes ) {

    $classes[] = ‘outreach-pro-home’;
    return $classes;

    }

    function outreach_home_top_widgets() {

    genesis_widget_area( ‘home-top’, array(
    ‘before’ => ‘<div class=”home-top widget-area”>’,
    ‘after’ => ‘</div>’,
    ) );

    }

    function outreach_home_bottom_widgets() {

    genesis_widget_area( ‘home-bottom’, array(
    ‘before’ => ‘<div class=”home-bottom widget-area”><div class=”wrap”>’,
    ‘after’ => ‘</div></div>’,
    ) );

    }

    genesis();

    From functions.php
    //* Hook after post widget after the entry content
    add_action( ‘genesis_after_entry’, ‘outreach_after_entry’, 5 );
    function outreach_after_entry() {

    if ( is_singular( ‘post’ ) )
    genesis_widget_area( ‘after-entry’, array(
    ‘before’ => ‘<div class=”after-entry widget-area”>’,
    ‘after’ => ‘</div>’,
    ) );

    }

    //* Modify the size of the Gravatar in the author box
    add_filter( ‘genesis_author_box_gravatar_size’, ‘outreach_author_box_gravatar_size’ );
    function outreach_author_box_gravatar_size( $size ) {

    return ’80′;

    }

    //* Remove comment form allowed tags
    add_filter( ‘comment_form_defaults’, ‘outreach_remove_comment_form_allowed_tags’ );
    function outreach_remove_comment_form_allowed_tags( $defaults ) {

    $defaults['comment_notes_after'] = ”;
    return $defaults;

    }

    //* Add the sub footer section
    add_action( ‘genesis_before_footer’, ‘outreach_sub_footer’, 5 );
    function outreach_sub_footer() {

    if ( is_active_sidebar( ‘sub-footer-left’ ) || is_active_sidebar( ‘sub-footer-right’ ) ) {
    echo ‘<div class=”sub-footer”><div class=”wrap”>’;

    genesis_widget_area( ‘sub-footer-left’, array(
    ‘before’ => ‘<div class=”sub-footer-left”>’,
    ‘after’ => ‘</div>’,
    ) );

    genesis_widget_area( ‘sub-footer-right’, array(
    ‘before’ => ‘<div class=”sub-footer-right”>’,
    ‘after’ => ‘</div>’,
    ) );

    echo ‘</div><!– end .wrap –></div><!– end .sub-footer –>’;
    }

    }

    //* Register widget areas
    genesis_register_sidebar( array(
    ‘id’ => ‘home-top’,
    ‘name’ => __( ‘Home – Top’, ‘outreach’ ),
    ‘description’ => __( ‘This is the top section of the Home page.’, ‘outreach’ ),
    ) );
    genesis_register_sidebar( array(
    ‘id’ => ‘home-bottom’,
    ‘name’ => __( ‘Home – Bottom’, ‘outreach’ ),
    ‘description’ => __( ‘This is the bottom section of the Home page.’, ‘outreach’ ),
    ) );
    genesis_register_sidebar( array(
    ‘id’ => ‘after-entry’,
    ‘name’ => __( ‘After Entry’, ‘outreach’ ),
    ‘description’ => __( ‘This is the after entry widget area.’, ‘outreach’ ),
    ) );
    genesis_register_sidebar( array(
    ‘id’ => ‘sub-footer-left’,
    ‘name’ => __( ‘Sub Footer – Left’, ‘outreach’ ),
    ‘description’ => __( ‘This is the left section of the sub footer.’, ‘outreach’ ),
    ) );
    genesis_register_sidebar( array(
    ‘id’ => ‘sub-footer-right’,
    ‘name’ => __( ‘Sub Footer – Right’, ‘outreach’ ),
    ‘description’ => __( ‘This is the right section of the sub footer.’, ‘outreach’ ),
    ) );

    If anyone can suggest the code to change all the widget titles to H2 would be much appreciated

    Thanks in Advance


    SEO & Online Marketing Consultant

    Metta3 | G+ | LinkedIn

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.