Direct link to image in WordPress functions.php

To get a responsive header image in WP (theme Skeleton by SimpleThemes), avoiding WP management of the image, I try to get the header image function to link directly to an image in my child_theme/image-folder.

function skeleton_child_logo() {
    // image
    if ( skeleton_options( 'logotype' ) ) :
        $skeleton_logo  = '<h1 id="site-title">';
        $skeleton_logo .= '<a class="logotype-img" href="'.esc_url( home_url( '/' ) ).'" title="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'" rel="home">';
        $skeleton_logo .= '<img src="'.skeleton_options( 'logotype' ).'" alt="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'"></a>';
        $skeleton_logo .= '</h1>';
    // text
    else :
        $skeleton_logo  = '<h1 id="site-title">';
        $skeleton_logo .= '<a class="text" href="'.esc_url( home_url( '/' ) ).'" title="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'" rel="home">'.esc_attr( get_bloginfo( 'name', 'display' ) ).'</a>';
        $skeleton_logo .= '</h1>';
        $skeleton_logo .= '<span class="site-desc">'.get_bloginfo('description').'</span>'. "n";
    endif;
    echo apply_filters ( 'skeleton_child_logo', $skeleton_logo);
}
add_action('skeleton_header','skeleton_child_logo', 4);

The function is placed in the child theme functions.php. I try to replace img src="'.skeleton_options( 'logotype' ).'" with img src="images/headerimagename.png" however the image does not appear.

Read More

How do I link directly to a specific image instead of an image defined by the options-function?

Related posts

1 comment

  1. You can’t use relative URLs like that. I recommend using get_stylesheet_directory_uri() to retrieve stylesheet directory URI for the current theme/child theme, and then append the image path to that:

    $skeleton_logo .= '<img src="'.get_stylesheet_directory_uri().'/images/headerimagename.png" alt="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'"></a>';
    

Comments are closed.