[Support request] How to add h1 tag in homepage

Home Forums Support How to add h1 tag in homepage

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1242649
    Tecnopeda

    Hello again.
    From my other post:
    “Hi, My homepage hasnt any h1 title.
    Im had check the option of hide page title and Im using a image.

    I had added that code using Code Snippet Pluging, but SEO Meta in 1 Click extension says that not h1 was found.

    any help?”

    Im using this code:

    add_filter( 'generate_site_title_output','tu_frontpage_h1_title' );
    function tu_frontpage_h1_title() {
    	printf(
    		'<%1$s class="main-title" itemprop="headline">
    			<a href="%2$s" rel="home">
    				%3$s
    			</a>
    		</%1$s>',
    		( is_front_page() ) ? 'h1' : 'p',
    		esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
    		get_bloginfo( 'name' )
    	);
    }
    #1242766
    David
    Staff
    Customer Support

    Hi there,

    try this:

    add_filter( 'generate_navigation_logo_output','db_navigation_logo_htag' );
    function db_navigation_logo_htag( $ouput ) {
        return sprintf(
            '<div class="site-logo">
            <h1>
                <a href="%1$s" title="%2$s" rel="home">
                    <img src="%3$s" alt="%4$s" />
                </a>
            </h1>
        </div>',
        esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
        esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
        esc_url( apply_filters( 'generate_navigation_logo', $settings['sticky_menu_logo'] ) ),
        esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
        );
    }

    And then some CSS just to remove any H1 styling that will mess up the logo:

    .site-logo h1 {
        margin-bottom: 0 !important;
        line-height: unset;
        font-size: 0;
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.