Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress默认徽标_Wordpress - Fatal编程技术网

Wordpress默认徽标

Wordpress默认徽标,wordpress,Wordpress,我正在研究一个新的Wordpress主题。 该主题将有一个选项,设置一个标志在定制作为正常。 这是有效的 但是,我希望主题自动设置默认徽标。 如果用户未在自定义程序中定义徽标,则默认徽标将自动显示。 我在主题根目录中的一个名为img的文件夹中有一个名为logo.jpg的图像 我正在使用此代码设置默认徽标,但它不起作用: add_filter('get_custom_logo',function($html){ if(empty($html)) { $html = '<img src

我正在研究一个新的Wordpress主题。 该主题将有一个选项,设置一个标志在定制作为正常。 这是有效的

但是,我希望主题自动设置默认徽标。 如果用户未在自定义程序中定义徽标,则默认徽标将自动显示。 我在主题根目录中的一个名为img的文件夹中有一个名为logo.jpg的图像

我正在使用此代码设置默认徽标,但它不起作用:

add_filter('get_custom_logo',function($html){
if(empty($html)) { 
   $html = '<img src = get_template_uri() . "/img/logo.jpg" >'; 
} 
return $html;
});
add_filter('get_custom_logo',函数($html){
if(空($html)){
$html='';
} 
返回$html;
});
有什么想法吗?是我的语法混合了“和”吗


谢谢!

您在字符串连接中出错

请注意,不要在过滤器中使用匿名函数。例如,在子主题中无法删除或更改此过滤器

add_filter( 'get_custom_logo', 'apply_default_logo' );
function apply_default_logo( $html ){
    if( empty( $html ) ) { 
        $html = '<img src="' . get_template_directory_uri() . '"/img/logo.jpg">'; 
    }
    return $html;
}
add_filter('get_custom_logo'、'apply_default_logo');
函数apply\u default\u logo($html){
if(空($html)){
$html='';
}
返回$html;
}

是。
'';
你好,尼克,谢谢你回来-非常感谢。你提供的代码没有显示任何错误,但也没有设置默认徽标。有什么想法吗?谢谢,@alanistration,函数名
get\u template\u uri()
你能尝试用
get\u template\u directory\u uri()替换它吗
?是的,我试过了,但没有成功-默认徽标仍然没有显示。下面是我正在使用的更新代码:添加过滤器('get_custom_logo','apply_default_logo');函数apply_default_logo($html){if(empty($html)){$html='';}返回$html;}