logo instead of title

Home Forums Theme Support logo instead of title

  • Question status -
  • Henny Zutt
    Participant

    How can i replace the site title for a small logo in the ArtemisMag theme ?

    Thanx!

    #4699
    Support Staff
    Keymaster

    Hi Henny!

    In functions.php in swt_theme_setup() function (after $prefix = hybrid_get_prefix(); ) add this:

    add_filter( "{$prefix}_site_title", 'my_custom_image' );

    Now add this function before swt_analytics2() function:

    function my_custom_image( $title ) {
    
            $tag = ( is_front_page() ) ? 'h1' : 'div';
            $title = get_bloginfo( 'name' );
            $site_url = get_option( 'siteurl' );
            $img = '<a title="'. esc_attr( $title ) .'" href="'. esc_url( $site_url ) .'"><img src="URL TO YOUR IMAGE" alt="'. esc_attr( $title ) .'" /></a>';
            $title = sprintf( '<%1$s id="site-title">%2$s</%1$s>', tag_escape( $tag ), $img );    
    
            return $title;
    
    }

    Just replace URL TO YOUR IMAGE with your image URL and that’s it.

    #4700
    Henny Zutt
    Participant
    This reply has been marked as private.
    #4701
    Support Staff
    Keymaster

    Hey Henny,

    you’re not suppose to change function name here:
    add_filter( "{$prefix}_site_title", 'my_custom_image' );

    Leave that.
    my_custom_image is name of the function in which you’ll change the image.

    In this function:

    function my_custom_image( $title ) {
    
            $tag = ( is_front_page() ) ? 'h1' : 'div';
            $title = get_bloginfo( 'name' );
            $site_url = get_option( 'siteurl' );
            $img = '<a title="'. esc_attr( $title ) .'" href="'. esc_url( $site_url ) .'"><img src="URL TO YOUR IMAGE" alt="'. esc_attr( $title ) .'" /></a>';
            $title = sprintf( '<%1$s id="site-title">%2$s</%1$s>', tag_escape( $tag ), $img );    
    
            return $title;
    
    }

    this will call the image, and this is where you need to add image URL:
    <img src="URL TO YOUR IMAGE" alt="'. esc_attr( $title ) .'" />

    You need to set change “URL TO YOUR IMAGE”, and set link to the image (full link, like http://my-site.com/myimage.jpg).

    I hope it’s more clear now. If you still need help, feel free to ask!

    #4702
    Henny Zutt
    Participant
    This reply has been marked as private.
    #4722
    Support Staff
    Keymaster

    Hi Henny!

    1. The same way as you did for Artemis, with one key difference:

    add_filter( 'hybrid_site_title', 'my_custom_image' );

    It’s not {$prefix}_site_title but hybrid_site_title (for newer themes).

    2. Upload that image to HeradinoMag/images folder, name it for example hover-image.png. Then find this in style.css .featured-post-title. Replace

    background: #000;
    with
    background: url(images/name-of-the-image.png) no-repeat;

    #4723
    Ali Öztürk
    Participant

    How can i replace the site title for a small logo in the Perses Mag theme ? Is it same like ArtemisMag?

    #4853
    Support Staff
    Keymaster

    Yes, it is the same.

    #4855
    Ali Öztürk
    Participant
    This reply has been marked as private.
    #4922
    Ali Öztürk
    Participant

    Can i add this logo to the header.php?

    #4923
    Support Staff
    Keymaster

    Hey Ali,

    the code is right, but I’ve missed to tell you that code will work only if you put it after this line:
    add_filter( "{$prefix}_site_title", 'site_title_span' );

    So, it would be like this:

    
    add_filter( "{$prefix}_site_title", 'site_title_span' );	
    
    add_filter( "{$prefix}_site_title", 'my_custom_image' );
    
    function my_custom_image( $title ) {
    
            $tag = ( is_front_page() ) ? 'h1' : 'div';
            $title = get_bloginfo( 'name' );
            $site_url = get_option( 'siteurl' );
            $img = '<a title="'. esc_attr( $title ) .'" href="'. esc_url( $site_url ) .'"><img src="URL TO YOUR IMAGE" alt="'. esc_attr( $title ) .'" /></a>';
            $title = sprintf( '<%1$s id="site-title">%2$s</%1$s>', tag_escape( $tag ), $img );    
    
            return $title;
    
    }
    
    #4930
    Ali Öztürk
    Participant
    This reply has been marked as private.
    #4941
    Support Staff
    Keymaster

    Glad you’re happy! 🙂

    #4943

You must be logged in to reply to this topic.

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