另一种方法是在<head>
.
唯一需要注意的是,以下内容不适用于子目录安装,仅适用于子域<不知怎的get_current_blog_id
is仅返回ID1
在何时define(\'SUBDOMAIN_INSTALL\', false);
.
<?php
/**
* Plugin Name: Multisite Favicons
* Description: Favicons should be stored in http://example.com/icons/domain_name.ico | If the site is subsite.example.com, the favicon should be subsite.ico
**/
add_filter( \'wp_head\', \'multisite_favicons_wpse_38903\' );
function multisite_favicons_wpse_38903()
{
// This function returns true if not Multisite
if( is_main_site() )
return;
global $current_site;
$details = get_blog_details( get_current_blog_id() );
$blogname =
( is_subdomain_install() )
? str_replace( \'.\' . $current_site->domain, \'\', $details->domain )
: $details->path;
printf(
"<link rel=\'shortcut icon\' href=\'%s/icons/%s.ico\' type=\'image/x-icon\'/>\\n",
site_url(),
$blogname
);
}
有趣的博客帖子:
Everything You Ever Wanted to Know about Favicons