• Stevied22

    (@stephenjdangelocom)


    Hello,
    I am using a child theme of the genesis sample theme. I am trying to have the header be a custom image rather than the site title and description. I inserted this code into the functions.php file:

    //* Add support for custom header
    add_theme_support( ‘custom-header’, array(
    ‘flex-width’ => true,
    ‘width’ => 400,
    ‘flex-height’ => true,
    ‘height’ => 150,
    ‘header-selector’ => ‘.site-title a’,
    ) );

    This allows me the option now to insert a header under appearance on my dashboard, as is explained here:

    However the result is my site title is appearing over-top of my header image. I am totally lost and could really use some help.

    Thank You!
    -Steve

Viewing 1 replies (of 1 total)
  • Add this in your child theme’s functions.php:

    /**********************************
     *
     * Replace Header Site Title with Inline Logo
     *
     * @author AlphaBlossom / Tony Eppright
     * @link https://www.alphablossom.com/a-better-wordpress-genesis-responsive-logo-header/
     *
     * @edited by Sridhar Katakam
     * @link https://sridharkatakam.com/use-inline-logo-instead-background-image-genesis/
     *
    ************************************/
    add_filter( 'genesis_seo_title', 'custom_header_inline_logo', 10, 3 );
    function custom_header_inline_logo( $title, $inside, $wrap ) {
    
    	$logo = '<img src="' . get_stylesheet_directory_uri() . '/images/header.png" alt="' . esc_attr( get_bloginfo( 'name' ) ) . ' Homepage" />';
    
    	$inside = sprintf( '<a href="%s">%s<span class="screen-reader-text">%s</span></a>', trailingslashit( home_url() ), $logo, get_bloginfo( 'name' ) );
    
    	// Determine which wrapping tags to use
    	$wrap = genesis_is_root_page() && 'title' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p';
    
    	// A little fallback, in case an SEO plugin is active
    	$wrap = genesis_is_root_page() && ! genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : $wrap;
    
    	// And finally, $wrap in h1 if HTML5 & semantic headings enabled
    	$wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h1' : $wrap;
    
    	return sprintf( '<%1$s %2$s>%3$s</%1$s>', $wrap, genesis_attr( 'site-title' ), $inside );
    
    }
    
    // https://sridharkatakam.com/how-to-remove-site-description-tagline-in-genesis/
    add_filter( 'genesis_attr_site-description', 'abte_add_site_description_class' );
    /**
     * Add class for screen readers to site description.
     *
     * Unhook this if you'd like to show the site description.
     *
     * @since 1.0.0
     *
     * @param array $attributes Existing HTML attributes for site description element.
     * @return string Amended HTML attributes for site description element.
     */
    function abte_add_site_description_class( $attributes ) {
    	$attributes['class'] .= ' screen-reader-text';
    
    	return $attributes;
    }

    References:

    https://sridharkatakam.com/use-inline-logo-instead-background-image-genesis/

    https://sridharkatakam.com/how-to-remove-site-description-tagline-in-genesis/

Viewing 1 replies (of 1 total)
  • The topic ‘Genesis Sample theme header logo’ is closed to new replies.