2015-10-28 26 views
1

要获得WP(主题骨架由SimpleThemes)一个响应报头的图像,避免了图像的WP管理,我试图让头部图像功能,直接链接到我的形象child_theme /图像文件夹中。直接链接到WordPress的图像的functions.php

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); 

该函数被放置在子主题functions.php中。我尝试用img src="images/headerimagename.png"替换img src="'.skeleton_options('logotype').'",但是图像未显示。

我如何直接链接到一个特定的形象,而不是通过选项功能定义的图像?

+0

我想'skeleton_options'是get_options(相同),如果它是你应该能够将url作为默认参数传递。类似'get_theme_mod('_ak_banner_image',AK_TEMPLATE_DIR_URI。'/images/slider/slide.jpg')'我已经使用了'get_theme_mod()',因为这对我来说更可取。 –

回答

1

您不能使用这样的相对URL。我建议使用get_stylesheet_directory_uri()检索样式表目录的URI当前主题/子主题,然后追加图像路径是:

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

非常感谢!图像出现! – Hans