[Resolved] Add h1 to Site Title Only on Home Page

This topic contains 1 reply, has 2 voices, and was last updated by  Andrew Misplon 4 months, 3 weeks ago.

  • Author
    Posts
  • #12790

    April
    Participant

    Hi,

    I used the below code from one of your previous posts to remove the h1 tag from the site title for all pages on the site. Is there a way to modify this so that the site title has a h1 tag just on the home page, but not any of the other pages?

    if ( ! function_exists( ‘ultra_display_logo’ ) ) :
    /**
    * Display the logo.
    */
    function ultra_display_logo() {
    $logo = siteorigin_setting( ‘header_logo’ );
    $logo = apply_filters( ‘ultra_logo_image_id’, $logo );

    if ( empty( $logo ) ) {
    if ( function_exists( ‘has_custom_logo’ ) && has_custom_logo() ) {
    the_custom_logo();
    return;
    }

    // Just display the site title.
    $logo_html = ‘<h2 class=”site-title”>’ . get_bloginfo( ‘name’ ) . ‘</h2>’;
    $logo_html = apply_filters( ‘ultra_logo_text’, $logo_html );
    }
    else {
    // Load the logo image.
    if ( is_array( $logo ) ) {
    list ( $src, $height, $width ) = $logo;
    }
    else {
    $image = wp_get_attachment_image_src( $logo, ‘full’ );
    $src = $image[0];
    $height = $image[2];
    $width = $image[1];
    }

    // Add the logo attributes.
    $logo_attributes = apply_filters( ‘ultra_logo_image_attributes’, array(
    ‘src’ => $src,
    ‘width’ => round( $width ),
    ‘height’ => round( $height ),
    ‘alt’ => sprintf( esc_html__( ‘%s Logo’, ‘ultra’ ), get_bloginfo( ‘name’ ) ),
    ) );

    if ( siteorigin_setting( ‘header_sticky’ ) && siteorigin_setting( ‘header_scale’ ) ) $logo_attributes[‘data-scale’] = ‘1’;

    $logo_attributes_str = array();
    if ( ! empty( $logo_attributes ) ) {
    foreach($logo_attributes as $name => $val) {
    if ( empty( $val ) ) continue;
    $logo_attributes_str[] = $name.’=”‘.esc_attr($val).'” ‘;
    }
    }

    $logo_html = apply_filters( ‘ultra_logo_image’, ‘‘ );
    }

    // Echo the image.
    echo apply_filters( ‘ultra_logo_html’, $logo_html );
    }
    endif;

    Thanks,
    April

    #12799

    Andrew Misplon
    Keymaster

    Sure, here we go: https://pastebin.com/WjXAhSfV

    You’ll also need to add to Custom CSS or Additional CSS:

    .site-header .site-branding p.site-title {
        display: block;
        font-size: 36.00002px;
        font-size: 2.57143rem;
        font-family: "Muli", sans-serif;
        font-weight: 300;
        letter-spacing: -1px;
        line-height: normal;
        margin: 0;
        transition: 0.3s;
        zoom: 1;
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Scroll to top